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

captionやtable、headline内のfootnote対応 #858

Merged
merged 9 commits into from
Jan 14, 2018
Merged

Conversation

kmuto
Copy link
Owner

@kmuto kmuto commented Oct 29, 2017

#668, #841

footnotemarkにするかどうかの判断は構造を見る必要がある(floatのcaptionやtable内など)。将来的にはtable内のbrの判断も同様に対処。

ただ、table内のセルはbuilderではなくcompilerでインラインタグが展開されている、といった実装の理由で無駄に複雑になっているきらいがある。
構造内の判定もinclude?で調べるのは複数の判定のときにはいまいちイケてない気がする…。

@takahashim
Copy link
Collaborator

あらゆるbuilderの状態管理をする必要はなさそうなので、とりあえずBuilder#in_caption?Builder#in_table?を作るのと、captionとtableのときだけ状態を変えるようなクラスを作ってそこで管理するのがいいんではないかと思いました。

class Builder
  # ...
  def builder_init_file
    @sec_counter = SecCounter.new(5, @chapter)
    @doc_status = ReVIEW::DocStatus.new()
  end

  # ...
  def in_table?
    @doc_status.in_table?
  end

  # ...
  def in_caption?
    @doc_status.in_caption?
  end
end

みたいなイメージです。

@kmuto
Copy link
Owner Author

kmuto commented Nov 4, 2017

なるほど、たしかにそっちのほうが綺麗そう。

ただ、このフラグ機能が必要なのって実質TeXだけなんですよね…。
latexbuilder固有で持たせるのでいいのかも。

@kmuto
Copy link
Owner Author

kmuto commented Nov 6, 2017

クラスではないですが、Builderに@doc_statusを持たせてシンプルにしてみました。
表などは先にinline_compileパースされちゃうので、compiler#read_commandにてブロック名を覚えさせるようにしています。

おおむね綺麗にできてはいるようなのですが、

= footnotetest@<fn>{f1}
//footnote[f1][F1]

AAA@<fn>{f2}
//footnote[f2][F2]

//table[id1][caption@<fn>{f3}]{
A	B@<fn>{f3-2}
//}

//footnote[f3][F3]
#@# これが4になってしまう?

//footnote[f3-2][F3-2]

のように、floatキャプションによってそのキャプションあるいは後の数字が1つ重複してしまう現象が発生しています。この場合にイレギュラー処理が必要だと、ちょっと厄介ですね…。

@kmuto
Copy link
Owner Author

kmuto commented Nov 6, 2017

footnotetextに指定すればひとまず順番にはなった。//footnoteをちゃんと登場順に並べないとまずい、ということには変わりないですが。

@kmuto kmuto changed the title [WIP] 構造をスタックで記憶させてみる captionやtable、headline内のfootnote対応 Nov 7, 2017
@takahashim
Copy link
Collaborator

takahashim commented Nov 7, 2017

@kmuto ちょっと今のmasterとずれてしまっているのでrebaseしてもよいですか?

takahashim@f59fb34 多分こんな感じになるはずです

@kmuto
Copy link
Owner Author

kmuto commented Nov 7, 2017

お、ありがとうございます。pushがうまくできなくて悩んでました。

@takahashim
Copy link
Collaborator

ではrebaseしますね。rebaseなので履歴消えてしまいます。

@kmuto
Copy link
Owner Author

kmuto commented Nov 10, 2017

これでマージしようかなと思っていたのですが、クラスファイルやTeXコンパイラによっては \protect\footnotemark じゃないほうがよいという可能性はあるでしょうか?> @munepi さん?

@kmuto
Copy link
Owner Author

kmuto commented Jan 14, 2018

footnotemarkまわりについては後々抽象化することを考えますが、ひとまず情報取得したい場面が多そうなのでまずはこれをマージします。

@kmuto kmuto merged commit 89b1646 into master Jan 14, 2018
@kmuto kmuto deleted the stack_structure branch January 14, 2018 03:49
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

Successfully merging this pull request may close these issues.

2 participants