Syntax highlighting using Mediawiki formatting: Difference between revisions

m
→‎{{header|Julia}}: newlines in quotes
m (→‎{{header|Julia}}: two word keyword with extra spaces handling)
m (→‎{{header|Julia}}: newlines in quotes)
Line 370:
} ''# nextChar''
 
=={{header|Julia}}==
''#= Keywords in Julia. Handles two word reserved keywords. #= Also ''
'' #= handles nested comments such as this. =# =#''
Line 439 ⟶ 436:
"""
Given a string, output a string that has been modified by adding surrounding
\'\' or \'\'\' bracketing for syntax highlighting of keywords and comments
"""
'''function''' partialhighlight(txt)
Line 458 ⟶ 455:
qlen = findfirst(r"(?<!\\)\"\"\""sa, txt[idx+3:'''end'''])
qlen == nothing &amp;&amp; error("error with terminator of quote at $idx")
app'''end'''!(outtxt, collect(replace(txt[idx:idx+qlen.stop+2], "\n" =&gt; "\n ")))
idx += qlen.stop + 3
'''else'''
Line 464 ⟶ 461:
qlen == nothing &amp;&amp; error("error with terminator of quote at $idx")
app'''end'''!(outtxt, collect(replace(txt[idx:idx+qlen.stop+1], "\n" =&gt; "\n ")))
outtxt['''end'''] == &apos;\n&apos; &amp;&amp; push!(outtxt, &apos; &apos;)
idx += qlen.stop + 2
'''end'''
Line 473 ⟶ 471:
idx += stop
'''else'''
newlinepos = something(findfirst(==(&apos;\n&apos;), txt[idx+1:'''end''']), len - idx)
newlinepos == nothing &amp;&amp; error("unterminated double quote at $idx")
app'''end'''!(outtxt, collect("''$(txt[idx:idx+newlinepos-1])''"))
idx += newlinepos
4,105

edits