Syntax highlighting using Mediawiki formatting: Difference between revisions
Syntax highlighting using Mediawiki formatting (view source)
Revision as of 21:20, 9 October 2023
, 7 months ago→{{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 && error("error with terminator of quote at $idx")
app'''end'''!(outtxt, collect(replace(txt[idx:idx+qlen.stop+2], "\n" => "\n ")))
idx += qlen.stop + 3
'''else'''
Line 464 ⟶ 461:
qlen == nothing && error("error with terminator of quote at $idx")
app'''end'''!(outtxt, collect(replace(txt[idx:idx+qlen.stop+1], "\n" => "\n ")))
outtxt['''end'''] == '\n' && push!(outtxt, ' ')
idx += qlen.stop + 2
'''end'''
Line 473 ⟶ 471:
idx += stop
'''else'''
newlinepos = something(findfirst(==('\n'), txt[idx+1:'''end''']), len - idx)
app'''end'''!(outtxt, collect("''$(txt[idx:idx+newlinepos-1])''"))
idx += newlinepos
|