-
Notifications
You must be signed in to change notification settings - Fork 115
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
Error: Unknown language: "plaintext code-output" #959
Comments
Hello @Seelengrab, thanks for reporting, as mentioned on Slack recently and consequently added in the README, the There were some significant changes in the latest minor release of highlight js which I didn't have the time to look into. For the next version of Franklin (~ around the corner), the logic to pre-render will be removed from Franklin and left to the user or to a separate package/plugin to make maintenance easier. Hope that makes sense |
That's a shame - as far as I could tell, this was the only way so far to get |
In 88ec5b9 I added the possibility to specify the # default (as before)
julia> fd2html("""
```!
5+7
```
""") |> println
→ evaluating code [_ceval_1] in (index.md)
<pre><code class="language-julia">5+7</code></pre>
<pre><code class="plaintext code-output">12</code></pre>
# setting the code_output_class to empty (what I think you want)
julia> fd2html("""
+++
code_output_class=""
+++
```!
5+7
```
""") |> println
→ evaluating code [_ceval_1] in (index.md)
<pre><code class="language-julia">5+7</code></pre>
<pre><code class="plaintext">12</code></pre> In the second one the output only has class Could you try (by adding Franklin master) and let me know whether that solves your issue? if so I'll do a patch release with it. |
I think I already have a better fix: diff --git a/src/converter/html/prerender.jl b/src/converter/html/prerender.jl
index dbbc819e..5f6b6bd8 100644
--- a/src/converter/html/prerender.jl
+++ b/src/converter/html/prerender.jl
@@ -46,7 +46,7 @@ highlight.js to pre-render them to HTML.
function js_prerender_highlight(hs::String)::String
# look for "<pre><code" and "</code></pre>" these will have been automatically generated
# and therefore the regex can be fairly strict with spaces etc
- matches = collect(eachmatch(r"<pre><code\s*(class=\"?(?:language-)?(.*?)\"?)?\s*>|<\/code><\/pre>", hs))
+ matches = collect(eachmatch(r"<pre><code\s*(class=\"?(?:(?:language-)?(?<lang>[^\ \">]+))?(?:\s+([^\ \">]+)?)*\"?)?\s*>|<\/code><\/pre>", hs))
isempty(matches) && return hs
# buffer to write the JS script
@@ -64,7 +64,7 @@ function js_prerender_highlight(hs::String)::String
cs = subs(hs, nextind(hs, matchrange(co).stop), prevind(hs, matchrange(cc).start))
# cs = escape_string(cs)
# lang
- lang = co.captures[2]
+ lang = co[:lang]
# un-escape code string
cs = html_unescape(cs) |> escape_string
# add to content of jsbuffer This regex extracts either the first class or whatever is written after I've chosen
Having that as part of the |
nice work and that makes a lot of sense, I'll review the PR and patch release, thank you! |
btw I'd be curious to see what you meant with |
Oh I was just using |
Ah right, so an alternative for you would also have been to generate a bundle with that. But it's great that we fixed the pre-rendering, thanks for your PR! |
Yes, it would have been my alternative :) I prefer prerendering, since it keeps download/runtime dependencies down (also prevents reflowing due to DOM manipulations through JS - greatly enhances website rendering). Images & embedded video already take up a lot of data, adding more than necessary just adds to that :/ |
I'm running into this error when trying to display some textoutput of my code while fully prerendering with highlight.js, i.e.
serve(prerender=true)
. Full error here:...long Franklin warning with all generated JS...
stacktrace:
Best I can tell, this is caused by this thing that's being passed to
highlight.js
:which is all autogenerated. I haven't figured out though where the language is coming from, all I know is that the way I generated that text was via some
julia:./code/output.jl
followed by\output{./code/output.jl}
. So I suspect the culprit is either there or in the thing that's passing this tohighlight.js
, which should beFranklin.jl/src/converter/html/prerender.jl
Lines 46 to 76 in 469e6fe
The text was updated successfully, but these errors were encountered: