Skip to content

Instantly share code, notes, and snippets.

@wtnabe
Last active May 17, 2022 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtnabe/3fa990bc30874cf0907e712f2b31fe15 to your computer and use it in GitHub Desktop.
Save wtnabe/3fa990bc30874cf0907e712f2b31fe15 to your computer and use it in GitHub Desktop.
#! /usr/bin/awk -f
BEGIN {
filename = ""
}
/<markuplint> ([^:])+: (.)/ { # filename
sub(/\:$/, "", $2)
if ($3 == "") {
filename = ""
} else {
filename = remove_dir($2)
}
}
/^ +[0-9]+:[0-9]+/ {
if (filename) {
line = sprintf("%s:%s: ", filename, $1)
$1 = ""
line = line sprintf("%s ", $0)
print line
}
}
#
# @param {string} filename
# @return {string}
#
function remove_dir(filename) {
sub(ENVIRON["PWD"] "/", "", filename)
return filename
}
@wtnabe
Copy link
Author

wtnabe commented May 13, 2022

markuplint の出力が

<markuplint> filename: ✗
  3:81  ✖  不正な文字は文字参照でエスケープするべきです character-reference 
  3:113 ✖  不正な文字は文字参照でエスケープするべきです character-reference 
  3:131 ✖  不正な文字は文字参照でエスケープするべきです character-reference 

みたいな感じで扱いにくい。上のスクリプトを

yarn -s markuplint --no-color -f simple <source> 2>&1 | ./markuplint-error-for-compilation-mode.awk

こんな感じで使うと

filename:line:col: error message
filename:line:col: error message
filename:line:col: error message
filename:line:col: error message
...

という形になってだいぶ扱いやすくなる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment