Rosetta Code/Find bare lang tags: Difference between revisions

Restore AutoHotkey code by Crazyfirex, but disable Rosetta Code's syntax highlighter.
m (removed perl artifact)
(Restore AutoHotkey code by Crazyfirex, but disable Rosetta Code's syntax highlighter.)
Line 26:
 
For more extra credit, use the [http://rosettacode.org/mw/api.php Media Wiki API] to test actual RC tasks.
 
=={{header|AutoHotkey}}==
''This code has no syntax highlighting, because Rosetta Code's highlighter fails with code that contains literal <nowiki></lang></nowiki> tags.''
 
Stole RegEx Needle from Perl
<pre><nowiki>task =
(
Description
 
<lang>Pseudocode</lang>
 
=={{header|C}}==
<lang C>printf("Hello world!\n");</lang>
 
=={{header|Perl}}==
<lang>print "Hello world!\n"</lang>
)
lang := "no lanugage", out := Object(lang, 0), total := 0
Loop Parse, task, `r`n
If RegExMatch(A_LoopField, "==\s*{{\s*header\s*\|\s*([^\s\}]+)\s*}}\s*==", $)
lang := $1, out[lang] := 0
else if InStr(A_LoopField, "<lang>")
out[lang]++
For lang, num in Out
If num
total++, str .= "`n" num " in " lang
MsgBox % clipboard := total " bare lang tags.`n" . str</nowiki></pre>
Output:
<pre>2 bare lang tags.
 
1 in no lanugage
1 in Perl</pre>
=={{header|Perl}}==
This is a simple implementation that does not attempt either extra credit.
Anonymous user