Closed yacinehmito closed 8 years ago
Thank you!
I updated the gem to account for #44. Please let me know if you encounter any problems with #44. The project as a whole needs quite a bit of work.
Jim
On Jun 27, 2016, at 9:47 PM, Yacine Hmito notifications@github.com wrote:
Thank you!
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/asciidoctor/asciidoctor-latex/issues/44#issuecomment-228854186, or mute the thread https://github.com/notifications/unsubscribe/AApgNzKGbVgUJ_gY0swxNvRHjoiq1g9Lks5qQCi2gaJpZM4I_U-K.
When using macros.tex
I now encounter the following error:
asciidoctor: ERROR: test.adoc: line 1: only book doctypes can contain level 0 sections
This does not happen if there are no macros.tex
file.
This happens regardless of the backend used.
This happens even when macros.tex
is empty.
However this does not prevent the document from being properly processed.
I think I found out why this happens.
The module lib/asciidoctor/latex/macro_insert.rb
prepends a passthrough block to the document.
But this block appears before the title, hence the error.
This is without grave consequences for the HTML backend but it adds junks to the .tex
file with the latex backend.
Final words: By inspecting the commit 0b7cd88, I concluded that I missed the actually bug because of the omission of the undocumented include_macros
attribute.
By using it, it would have indeed added the div
to the HTML backend, and only the HTML backend.
Two problems would be remaining:
. Macros would be included in the tex
file regardless of the include_macros
attribute
. The innocent error message above would be printed when using the HTML backend
This is of course what would have happened if I used include_macros
with a version prior to the 0b7cd88 commit.
In light of this, I think the final fix would be to directly inject the div
into the HTML tree in place of the MacroInsert
processor. I don't know if or how this is feasible though. I'll be happy to hack a solution if I ever find time to dig into it.
Very good analysis! I think your proposal is the right one. This probably requires a tree processor -- something I have not used yet. If you find a solution, please let me know. In the meantime, I will look into it also.
I'm going to try a different strategy by introducing a block macro that works like this:
include_latex::macros.tex[]
with the general form
include_latex::PATH_TO_MACRO_FILE[]
I should have this ready shortly. If it works, I will remove the automatic inclusion of macros.tex
I've made the following changes:
(1) Eliminate automatic inclusion of macros.tex
if it is present.
(2) Introduce the block macro include_latex_macros::LATEX_FILE
, where LATEX_FILE is
typically a LaTeX style or macro file, or a path thereto. For the HTML backend, the file is included
in the source text as \( FILE CONTENTS \)
. For the tex backend it is included as-is.
If you find that this change works for you, you can close this issue. I very much appreciate your contributions to this project!
Thank you, this makes me feel very welcome.
I like the solution as it can also serve a wider range of use-cases.
From the quick tests I did, this seems to work, although there still are some irrelevant warnings. I'll give you more details when I'll find how to use the development version on my main computer (I have some trouble with gem paths unrelated to asciidoctor-latex). I expect this to be solved in less than 24 hours. I'll close the issue if it is not done before.
This works like a charm!
Note that, because macros are inserted in the text, you cannot use this new feature as a drop-in replacement for the macros.tex
inclusion. Indeed macros were previously added in the preamble, which allowed the use of "preamble-only" macros (such as \DeclareMathOperator
).
This is not a problem though. Such macros can be included with preamble.tex
for the latex backend and docinfo.html
for the html backend (macros included in the header work, at least on recent versions of Chromium).
The README states:
However, it is not the case for the HTML format.
Tested with the versions 1.5.0.11.dev and 1.5.0.8.dev.
Steps to reproduce
Setup
Create a
test.adoc
file:In the same directory, create a
macros.tex
file:Latex backend: no problem
Do:
The command
\dummymacro
shows up in the preamble oftest.tex
, under the line%User defined macros
.Html backed: no macro
Do:
The string
dummymacro
intest.html
is nowhere to be found.