Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved test, fix for multiple codeblocks, code quality and comments #1

Merged
merged 4 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improved test, removing trailing whitespaces
  • Loading branch information
sezanzeb committed Oct 12, 2021
commit 65b3a6999fdba2effd9ec80dab85c5f3af129695
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
tests/result.pango
.idea
.vscode
.bin
dist
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ src/bin/md2pango: src/md2pango.js
cat src/md2pango.js >> $@

TESTS=all
test: ; ./test.sh $(TESTS)
test: ; ./tests/test.sh $(TESTS)
reuse: ; reuse addheader src/*.js -y 2021 -l MIT -c 'Uwe Jugel'
4 changes: 4 additions & 0 deletions src/bin/md2pango
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ function convert(text) {
}

try_close_span()

// remove trailing newlines
output = output.map(line => line.replace(/ +$/, ''))

return output.join('\n')
}

Expand Down
4 changes: 4 additions & 0 deletions src/md2pango.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ function convert(text) {
}

try_close_span()

// remove trailing newlines
output = output.map(line => line.replace(/ +$/, ''))

return output.join('\n')
}

Expand Down
42 changes: 42 additions & 0 deletions tests/expected.pango
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<big><big><big>T1</big></big></big>

<span foreground='#aaa' background='#444'>
<tt>
&lt;html&gt;
&lt;tag&gt;
&lt;/tag&gt;
&lt;/html&gt;
</tt>
</span>

<span foreground='#bbb' background='#222'><tt>
# default colored
--&gt; more
&lt;-- code
</tt></span>

<big><big>T2</big></big>

1. first
2. second
3. third

<big>T3</big>

• a
• b
• c

full link: <a href='https://example.com'>https://example.com</a>
named link: <a href='https://example.com'>link</a>
URI: https://example.com

<b>bold</b> <i>emph</i> inline <tt>code</tt> example
<b><tt>bold code</tt></b>
<b>bold <i>emph</i></b>
<b><i>bold-emph</i></b>
<i>emph <b>bold</b> emph</i>

<span foreground='red' background='orange'>
<big><big>Red T2</big></big>
</span>
File renamed without changes.
9 changes: 5 additions & 4 deletions test.sh → tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ fail() { echo -e "[FAIL] $*"; exit 1; }
ok() { echo -e "[OK] $*\n"; }

test_md2pango() {
lines=$(node src/md2pango.js *.md | wc -l) &&
test "$lines" -gt 150 ||
fail "unexpected pango output, got $lines lines, expected > 150"
ok "Output looks good! ($lines lines)"
set -e
node src/md2pango.js tests/test.md > tests/result.pango
diff "tests/result.pango" "tests/expected.pango" ||
fail "tests/result.pango does not match tests/expected.pango"
ok "Output looks good!"
}

test_lint() {
Expand Down