-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
issues with es6 template strings #259
Comments
I see your point but this is hardly a showdown issue. To further elaborate... Tabs and spaces at the beginning of lines are meaningful in markdown syntax. var conv = new showdown.Converter();
conv.makeHtml(
`
this is
a multiline
piece of code
`); Also, the indentation at the beginning of lines is arbitrary, depending of your code style and how deep in the code is the markdown text. This makes it hard to implement at best.... @jhicken Do you have any suggestion? |
To fix your specific issue, however, you have several options: Move es6 template strings to a new lineYou can fix the issue by moving the es6 opening mark to a new line that respects your indentation: function masterRunner() {
var conv = new showdown.Converter()
return conv.makeHtml(
`## markdown doc
you can use markdown for card documentation
- foo
- bar`);
} Use a wrapper functionyou can also use a wrapper function, although I think is really an overkill and potentially breaks tab code blocks: function masterRunner(){
var conv = new showdown.Converter()
return conv.makeHtml(t(`
## markdown doc
you can use markdown for card documentation
- foo
- bar
`));
}
function t(txt) {
return txt.replace(/^\s+/gm, '');
} Make the above t function a lang extensionThis would remove the need to pre-parse the text but, again, I think is an overkill. |
Hey thanks for the response. So If i use option 1 (Move es6 template strings to a new line) This is what i get. The first line is converted and nothing else.
the alternative is
Which is also not super great. (this is what im currently doing) Using something like option 2 up above would work but would need some major testing to make sure you don't remove white space from unintended lines. My proposal is that showdown could let you pass an argument that would try to intelligently fix your es6 string. Is that crazy? |
Yeah, but how would we accomplish that? Right trimming would not work as it would remove important right whitespaces. The only way I can think of is guessing by the the "indentation" level of the first line of the text, but that would also break under some circumstances such as:
So what did you have in mind to tackle the problem? |
Check 261f127 and see if it fixes your problem, Its on it's own branch since I would like further testing before introducing this feature on core. |
I have not. Sorry been super busy. I'll try and get to it tonight. Ps thanks for working on this. |
Imagine a function like this...
this is the output
It means i always have to untab my markdown.
I understand why but it seams ungood.
The text was updated successfully, but these errors were encountered: