Created
December 1, 2020 05:06
-
-
Save uchan-nos/448e0fb49592df3c119ca732891de34e to your computer and use it in GitHub Desktop.
Re:VIEWでPDF生成時にだけダブルクオートを``と''に変換するインラインタグを定義する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
使用例
PDFへの出力:“hello”
HTMLへの出力:"hello"