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

Directly adjacent instances of raw source cause parsing error #115

Closed
ghost opened this issue Mar 4, 2018 · 7 comments
Closed

Directly adjacent instances of raw source cause parsing error #115

ghost opened this issue Mar 4, 2018 · 7 comments

Comments

@ghost
Copy link

ghost commented Mar 4, 2018

When inserting raw LaTeX using the new marker system for doing so, if two instances of insertion are done back to back then the parser seems to fail to recognise one of the spans:

 This will render `\bfseries{`{=latex}properly`}`{=latex}.

And for a failing case:

This will cause `\`{=latex}`bfseries{`{=latex}errors`}`{=latex}.

The second example will produce the following output:

Unknown token type: 121
* (121) 55:8	'{=latex}'
	* (204) 55:2	'{='
	* (216) 57:5	'latex'
	* (206) 62:1	'}'
This will cause \texttt{\textbackslash{}`{=latex\}}bfseries\{\texttt{{=latex\}errors}\}`.
@ghost
Copy link
Author

ghost commented Mar 4, 2018

I should also add that it would help to report where in the source file the problem was encountered. That might be happening, but if so it is using a system that isn't easy to follow up on (total bytes from start of file?). It might be better to report line numbers at least.

@fletcher
Copy link
Owner

fletcher commented Mar 4, 2018

It did report exactly where the problem was encountered (in byte offsets, which is how MMD "thinks"), and even showed you the exact text at the problem area.

But an error report means that I left a particular token type out of the output processing, since in theory there should never be any errors in a MMD document, just things that don't work the user thought they would due to a misunderstanding of the syntax rules.

In this case, there is a bug, but it's not what you think. The final {=latex} causes the error message because it is not attached to a code span, and I failed to include an option for outputting that token when it was used incorrectly. From your message, I think you miscounted the backticks (or forgot to account for the fact that you escaped the second backtick?).

But the error message is easily resolved and will be fixed shortly.

@fletcher fletcher closed this as completed Mar 4, 2018
@ghost
Copy link
Author

ghost commented Mar 4, 2018

Ah, I think I see what you mean, I hadn't consciously factored in that \ would not be a naked backslash and would rather be an escaped backtick. This was a solution ported directly from the older HTML comment method, where the code would have been <!--\--><!--bfseries{-->. Doing a blanket replace of HTML to backtick nomenclature caused the imbalance to appear.

So the question then becomes, how can one insert a backslash all by itself like that? I should be able to work around having done things that way in the past with a few tweaks to my generator, but just out of curiosity:

`\\`{=latex}

Rightly inserts two backslashes into the output.

Or for that matter (though it was not what I was trying to do), how can one get a backtick into the LaTeX output, since:

`\`\`this''`{=latex}

Produces:

\`\`this''

@fletcher
Copy link
Owner

fletcher commented Mar 4, 2018

You use a backslash normally inside code spans. The only thing you can't do (I think) is a backslash immediately before the final backtick -- you can use a space to separate the backslash from the backtick, e.g.:

`foo\ `

@fletcher
Copy link
Owner

fletcher commented Mar 4, 2018

(By normally I mean as you want it to appear in the output.)

@ghost
Copy link
Author

ghost commented Mar 4, 2018

Yes, that's exactly what I mean though, if for some reason you need to terminate the block at a backslash it seems the only way around the problem is to avoid ever having to do so. Probably not too big of a constraint all things considered. It's a bit of an odd case as I had two different operations generating different pieces of code. I can combine their total output effect to avoid this happening.

@fletcher
Copy link
Owner

See #133 for further discussion on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant