Skip to content

Instantly share code, notes, and snippets.

@uchan-nos
Created December 1, 2020 05:06
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 uchan-nos/448e0fb49592df3c119ca732891de34e to your computer and use it in GitHub Desktop.
Save uchan-nos/448e0fb49592df3c119ca732891de34e to your computer and use it in GitHub Desktop.
Re:VIEWでPDF生成時にだけダブルクオートを``と''に変換するインラインタグを定義する
module ReVIEW
module LATEXBuilderOverride
Compiler.definline :dquote
def inline_dquote(s)
"``" + s + "''"
end
end
class LATEXBuilder
prepend LATEXBuilderOverride
end
module HTMLBuilderOverride
Compiler.definline :dquote
def inline_dquote(s)
'"' + s + '"'
end
end
class HTMLBuilder
prepend HTMLBuilderOverride
end
end
@uchan-nos
Copy link
Author

使用例

@<dquote>{hello}

PDFへの出力:“hello”
HTMLへの出力:"hello"

@uchan-nos
Copy link
Author

kmutoさんが別解を作ってくださった。こちらはインラインタグを新設しない方法なのですっきりしている。
https://gist.github.com/kmuto/1629b3ae357ec287efe221288a960753

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