-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[CS2] Fix handling of tabbed code blocks in .litcoffee files #4485
Merged
+227
−93
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6a31359
Add tabbed literate test; modernize Markdown title heading
GeoffreyBooth 17c7333
Better parsing of Literate CoffeeScript files, including now correct …
GeoffreyBooth d9e1fd4
Swap Marked for MarkdownIt for parsing the Markdown of Literate Coffe…
GeoffreyBooth 3585d2a
Literate CoffeeScript tests: remove trailing whitespace, fix spelling
GeoffreyBooth c166486
Literate CoffeeScript tests: add block quote test
GeoffreyBooth a3d6f27
Literate CoffeeScript (tabbed, at least) seems to need a consistent s…
GeoffreyBooth 5826ca9
Restore test
GeoffreyBooth b401f84
Reference links work now in MarkdownIt
GeoffreyBooth b8eed42
Breaking change in Literate CoffeeScript: code blocks within HTML tag…
GeoffreyBooth 7705438
Breaking change in Literate CoffeeScript: code blocks within lists ne…
GeoffreyBooth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
Literate CoffeeScript Test | ||
-------------------------- | ||
# Literate CoffeeScript Test | ||
|
||
comment comment | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
# Tabbed Literate CoffeeScript Test | ||
|
||
comment comment | ||
|
||
test "basic literate CoffeeScript parsing", -> | ||
ok yes | ||
|
||
now with a... | ||
|
||
test "broken up indentation", -> | ||
|
||
... broken up ... | ||
|
||
do -> | ||
|
||
... nested block. | ||
|
||
ok yes | ||
|
||
Code must be separated from text by a blank line. | ||
|
||
test "code blocks must be preceded by a blank line", -> | ||
|
||
The next line is part of the text and will not be executed. | ||
fail() | ||
|
||
ok yes | ||
|
||
Code in `backticks is not parsed` and... | ||
|
||
test "comments in indented blocks work", -> | ||
do -> | ||
do -> | ||
# Regular comment. | ||
|
||
### | ||
Block comment. | ||
### | ||
|
||
ok yes | ||
|
||
Regular [Markdown](http://example.com/markdown) features, like links | ||
and unordered lists, are fine: | ||
|
||
* I | ||
|
||
* Am | ||
|
||
* A | ||
|
||
* List | ||
|
||
Spaces work too: | ||
|
||
test "spaced code", -> | ||
ok yes | ||
|
||
--- | ||
|
||
# keep track of whether code blocks are executed or not | ||
executed = false | ||
|
||
<p> | ||
|
||
executed = true # should not execute, this is just HTML para, not code! | ||
|
||
</p> | ||
|
||
test "should ignore indented sections inside HTML", -> | ||
eq executed, false | ||
|
||
--- | ||
|
||
* A list item with a code block: | ||
|
||
test "basic literate CoffeeScript parsing", -> | ||
ok yes | ||
|
||
--- | ||
|
||
* Lorem ipsum dolor sit amet, consectetuer adipiscing elit. | ||
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, | ||
viverra nec, fringilla in, laoreet vitae, risus. | ||
|
||
* Donec sit amet nisl. Aliquam semper ipsum sit amet velit. | ||
Suspendisse id sem consectetuer libero luctus adipiscing. | ||
|
||
--- | ||
|
||
1. This is a list item with two paragraphs. Lorem ipsum dolor | ||
sit amet, consectetuer adipiscing elit. Aliquam hendrerit | ||
mi posuere lectus. | ||
|
||
Vestibulum enim wisi, viverra nec, fringilla in, laoreet | ||
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum | ||
sit amet velit. | ||
|
||
2. Suspendisse id sem consectetuer libero luctus adipiscing. | ||
|
||
--- | ||
|
||
1. This is a list item with two paragraphs. Lorem ipsum dolor | ||
sit amet, consectetuer adipiscing elit. Aliquam hendrerit | ||
mi posuere lectus. | ||
|
||
Vestibulum enim wisi, viverra nec, fringilla in, laoreet | ||
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum | ||
sit amet velit. | ||
|
||
2. Suspendisse id sem consectetuer libero luctus adipiscing. | ||
|
||
--- | ||
|
||
* A list item with a blockquote: | ||
|
||
> This is a blockquote | ||
> inside a list item. | ||
|
||
--- | ||
|
||
This next one probably passes because a string is inoffensive in compiled js, also, can't get `marked` to parse it correctly, and not sure if empty line is permitted between title and reference | ||
|
||
This is [an example][id] reference-style link. | ||
[id]: http://example.com/ | ||
|
||
"Optional Title Here" | ||
|
||
--- | ||
|
||
executed = no | ||
|
||
1986. What a great season. | ||
executed = yes | ||
|
||
and test... | ||
|
||
test "should recognise indented code blocks in lists", -> | ||
ok executed | ||
|
||
--- | ||
|
||
executed = no | ||
|
||
1986. What a great season. | ||
|
||
executed = yes | ||
|
||
and test... | ||
|
||
test "should recognise indented code blocks in lists with empty line as separator", -> | ||
ok executed | ||
|
||
--- | ||
|
||
executed = no | ||
|
||
1986\. What a great season. | ||
executed = yes | ||
|
||
and test... | ||
|
||
test "should ignore indented code in escaped list like number", -> | ||
eq executed, no | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about multiline strings and regexes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code
here is the source code of an entire file. This function is intending to replace all leading tabs (between the start of any line and the first non-tab character) with 2 spaces × the number of leading tabs on that line. Does it not do that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m worried that it changes the meaning of mulitline strings and regexes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps only replacing the first tab on each line is enough?
code.replace /^\t/gm, ' '
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was the previous approach, replacing the first tab with a tab plus a magic token. Then after the parsing by Marked, the tab plus token were replaced back with a tab. For some reason I was getting lots of compiler errors regarding indentation when I did that, that I couldn't figure out. I'll look into it some more.