Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

review-ext.rb で texequation を Override すると _ が textunderscore に置換されてしまう #1498

Closed
oipest opened this issue Apr 17, 2020 · 4 comments

Comments

@oipest
Copy link

oipest commented Apr 17, 2020

review-ext.rb を

module ReVIEW
    module LATEXBuilderOverride
        def texequation(lines, id = nil, caption = '')
        blank

        if id
            puts macro('begin', 'equation')
            puts macro('label', id)
        else
            puts macro('begin', 'equation*')
        end

        lines.each do |line|
            puts line
        end

        if id
            puts macro('end', 'equation')
        else
            puts macro('end', 'equation*')
        end

        blank
        end
    end

    class LATEXBuilder
      prepend LATEXBuilderOverride
    end
end

とし、本文ファイル(000.re)に

//texequation[][]{
F=m_a
//}

と記述すると、生成される 000.tex ファイルの中で

\begin{equation*}
F=m\textunderscore{}a
\end{equation*}

となってしまいます。

\begin{equation*}
F=m_a
\end{equation*}

にはなりませんか?
defineblock した場合も同様の現象です。

@kmuto
Copy link
Owner

kmuto commented Apr 17, 2020

Re:VIEW 3.2あたりでしょうか。4.0で修正しており、現在は4.1が最新リリースです。

ref #1371 #1374

@oipest
Copy link
Author

oipest commented Apr 18, 2020

ありがとうございます。gem update していたのですが、3.1がインストールされていました。削除して再度インストールしたら4.1になって、解決されました。

Compiler.defblock :texeqnarray, 0..2
def texeqnarray(lines, id = nil, caption = '')
blank

if id
    puts macro('begin', 'eqnarray')
else
    puts macro('begin', 'eqnarray*')
end

lines.each do |line|
    puts line
end

というものも用意したのですが、Compiler::do_compile を
オーバーライドして @non_parsed_commands = %i[embed texequation graph texeqnarray] としました。

@oipest oipest closed this as completed Apr 18, 2020
@oipest oipest reopened this Apr 18, 2020
@oipest oipest closed this as completed Apr 18, 2020
@oipest
Copy link
Author

oipest commented Apr 18, 2020

compiler.rb の 228行目 で

@non_parsed_commands = %i[embed texequation graph]

としていますが、

    def initialize(strategy)
      @strategy = strategy

      ## commands which do not parse block lines in compiler
      @non_parsed_commands = %i[embed texequation graph]

      ## to decide escaping/non-escaping for text
      @command_name_stack = []
    end

で入れているので、不要な気がします。228行目がなければ、overrideする側は

      def initialize(strategy)
      super

      ## commands which do not parse block lines in compiler
      @non_parsed_commands = %i[embed texequation graph texeqnarray]
      end

だけで済むような気がします。

@kmuto
Copy link
Owner

kmuto commented Apr 18, 2020

おっと。これは私が入れ込んでしまったようですね…。
Issue #1499 を作りました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants