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

Support for LaTeX #1

Open
jirutka opened this issue Dec 11, 2014 · 7 comments
Open

Support for LaTeX #1

jirutka opened this issue Dec 11, 2014 · 7 comments

Comments

@jirutka
Copy link
Member

jirutka commented Dec 11, 2014

@jxxcarlson I’ve prepared some basic support for LaTeX backend in the latex branch. The only added file is doctest/latex/examples_suite (DocTest::Latex::ExamplesSuite) and its spec.

ExamplesSuite class is responsible for parsing and serializing of example groups in a particular format (e.g. HTML, LaTeX…). Examples group is a file that may contain many examples (it’s described here). Each example is delimited with a header that must contain the name (identifier) and optionally description and options (see example). ExamplesSuite#parse must parse the example’s header (i.e. name, options…) and read (not parse!) the actual content. It doesn’t matter what the content is at this moment (if LaTeX or HTML), but it must be distinguishable from the header.

In the case of AsciiDoc (example) and HTML (example) I’ve decided to write header as a comment, so the examples group file is a valid AsciiDoc and HTML document respectively (you know, for syntax highlighting and stuff like that). Backend typically doesn’t produce comments, so it’s okay here. Not in your case though. Your backend is producing a lot of commented boilerplate, so we have to agree on some special syntax to distinguish a regular LaTeX comment from the example’s header.

I’m thinking about something like this:

%====
% .first_example
% Each example must be preceded by a header (comment); the first line must
% contain the example’s name prefixed with a dot. This text is interpreted
% as a description.
%====
The example’s content in \textbf{LaTeX}.

The trailing new line (below this) will be removed.

%====
% .second_example
% You may also specify options for comparing or Asciidoctor renderer. Option
% line starts with a semicolon, then comes the option name ended by a
% semicolon and after that the option’s value (may be omitted for boolean
% options).
% :option_1: value 1
% :option_2: value 1
% :option_2: value 2
% :boolean_option:
%====
\begin{enumerate}
  \item The first item
  \item The second item
  \item The third etc \ldots
\end{enumerate}

What do you think? Won’t it interfere with some LaTeX syntax that you may use in your backend?


For the record, this discussion started in asciidoctor/asciidoctor-latex#13.

@jirutka
Copy link
Member Author

jirutka commented Dec 11, 2014

Hm, I don’t like about this style that it’s too verbose in the most common case (name only):

%====
% .strong
%====
\textbf{chunky bacon}

@jirutka
Copy link
Member Author

jirutka commented Dec 15, 2014

Gentle reminder, @jxxcarlson.

@jxxcarlson
Copy link

I've merged #2, pulled it back to my machine and ran several files in try-out through asciidoctor. All OK.

@jirutka
Copy link
Member Author

jirutka commented Dec 15, 2014

This comment belongs to jxxcarlson/asciidoctor-latex#2, isn’t it?

@jxxcarlson
Copy link

Correct.

@jirutka
Copy link
Member Author

jirutka commented Dec 15, 2014

I’ve changed syntax of the example’s header to be more specific — to not interfere with regular comments produced by the backend (see ace99e9):

Format of the example's header:

%== .example_name
% Any text that is not the example's name or an option is considered
% as a description.
% :option_1: value 1
% :option_2: value 1
% :option_2: value 2
% :boolean_option:
%==
The example's content in \LaTeX.

The trailing new line (below this) will be removed.

Format of the example's header with name only:

%== .example_name ==%
The example's content in \LaTeX.

To use it in test:

class TestBackend < DocTest::Test
  renderer_opts backend_name: :latex
  generate_tests! DocTest::Latex::ExamplesSuite
end

The next thing we have to solve is how to remove LaTeX boilerplate from examples. I’ll write more later.

@jxxcarlson
Copy link

Agreed on LaTeX boilerplate. That was really bothering me.

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

No branches or pull requests

2 participants