Coder Social home page Coder Social logo

asciidoctor / asciidoctor-latex Goto Github PK

View Code? Open in Web Editor NEW
111.0 16.0 26.0 1.47 MB

:triangular_ruler: Add LaTeX features to AsciiDoc & convert AsciiDoc to LaTeX

Home Page: http://asciidoctor.org

License: Other

Ruby 49.43% HTML 3.21% TeX 27.33% CSS 17.87% JavaScript 2.17%

asciidoctor-latex's People

Contributors

blipp avatar dbroeglin avatar ggrossetie avatar jagedn avatar jirutka avatar jxxcarlson avatar mattpalermo avatar mojavelinux avatar otavio avatar tribut avatar yacinehmito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asciidoctor-latex's Issues

Unable to push

Made a few changes, tried to push, got:

remote: Permission to asciidoctor/asciidoctor-latex.git denied to jxxcarlson.
fatal: unable to access 'https://github.com/asciidoctor/asciidoctor-latex.git/': The requested URL returned error: 403

I am in Beijing till Dec 2 --- ti could be that, though I have been able to push and pull on other repositories. Many sites are blocked here.

@mojavelinux, I am readiy to work on mapping [env.?] to ? as soon as the issues in #1 are settled.

(Maybe I need to make a PR instead?)

Add support for docinfo files in LaTeX backend

Add support for docinfo files in the LaTeX backend. docinfo gives the author a hook to inject extra content into the header and footer of the generated document. This is how the author could add additional LaTeX typesetting, packages and so forth.

The docinfo files would be named as follows:

  • docinfo.tex
  • docinfo-footer.tex
  • -docinfo.tex
  • -docinfo-footer.tex

The details of resolving, locating and reading the docinfo file are handled internally. What the LaTeX converter needs to be concerned with is where the content is inserted in the generated document.

You can see how it's done in the HTML5 backend here: https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/converter/html5.rb#L128

.cls file based latex styles for standard research publications support in asciidoctor-latex, just like doconce?

doconce= https://github.com/hplgit/doconce (superset of markdown)

'doconce latex output' - supports "latex styles", such that i can give command

     doconce format pdflatex mydoc --latex_style=elsevier

then it will format mydoc.do.txt to tex with latex style "elsevier.cls" and use pdflatex to produce pdf

doconce also supports following types of latex styles, which are useful to produce research papers

--latex_style=std, Springer_lncse, Springer_llncs, Springer_lnup, Springer_T2, siamltex, siamltexmm, elsevier

( reference see= http://hplgit.github.io/doconce/doc/pub/manual/html/manual.html#latex )
that is, we can easily write springer journals ,elsevier journal etc research papers using doconce format.

whether asciidoctor-latex supports latex styles/.cls for producing research papers?? Whether we will have to tinker with the produced .tex files, or there is any syntax in asciidoctor-latex for this?
I searched in online manual ( https://vschool.s3.amazonaws.com/manuscripts/389.html#_design_of_the_html_backend ), but could not find any.

Probably this needs to be kept in roadmap for future.


references =
elsarticle latex style class (from elsevier):
http://www.elsevier.com/authors/author-schemas/latex-instructions#elsarticle

springer latex style class:
https://www.sharelatex.com/templates/journals/svjour3-%28springer-journals%29

https://www.springer.com/gp/authors-editors/book-authors-editors/manuscript-preparation/5636
-> and then click "LaTeX template" section

Appearance of block_dlist for tex backend

@jirutka, could you take a look at block_dlist for the tex backend? I think it is fine except for an esthetic point: when an item is a sublist, the sublist should start on new line. If this is something you could address, that would be great. Is the dlist code yours? I don't recognze it. Looks too pro:-)

Underscore being wrongly interpreted as $_$

The following adoc file triggers the problem:

=== Underscore use bug

[quote]
This is a quote which uses a MACRO_NAME to trigger a bug

Building the generated .tex file raises:

(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/se-ascii-print.def)
! Missing $ inserted.
 
                $
l.113 This is a quote which uses a MACRO_
                                         NAME to trigger a bug\end{quote}
?

asciidoctor -r $laco -a stem:latexmath fails to insert MathJax javscript

Let $laco point to the LaTeX backend. Then $ asciidoctor -r $laco foo succeeds (after the addition of @mojavelinux's code toconverter.rb). However, theMathJaxjavascript code is not inserted in the HTML file for some reason. This is is true even if the body of the document contains:stem: latexmath`.

Use caption for counter instead of $counter

@mojavelinx, could you look at commit 7c04ed500c227aed1eec206aab59a2eed1e914c8 in the counter branch of my asciidcotor-latex? I've been trying to understand how to use captions for numbering per your suggestion:

Asciidoctor has built-in support for counter numbers. Here's how it's done.


attrs['title'] = env_name.capitalize
caption = attrs.delete 'caption'
block = create_block parent, :environment, reader.lines, attrs
block.assign_caption caption, 'environment'
block


You can see that it handles all the logic of increment and adding the counter 
number to the title in this method:

I must be missing something because caption always seems to be nil.

See code at jxxcarlson@7c04ed5

Better css for printing

This is related to the previous issue. The additional css for printing is

body { margin-left:6em;
       margin-right:6em;
       font-size: 10pt; }

The margin modifications work fine, but the body font-size doesn't modify everything. What is the best way to do this?

Cost of sponsoring/donating for asciidoctor-latex

(disclaimer: i am just a lone individual pouring my own pocket money out of love to asciidoctor, i am not a commercial organisation)

how much will it cost to sponsor a dedicated freelancer developer working on asciidoctor-latex backend within a definite timeframe, where the definition of completion is defined as :

step1)

"entire user manual of asciidoctor" is rendered to tex file - using asciidoctor-latex , such that
when the generated tex file is converted to pdf using pdflatex/xelatex/lualatex on 'ubuntu 14.04 /or on MS-Windows' then there is 'not a single error or warning (vv important).' This test has to be applied only to user manual of asciidoctor, not to an arbitrary document.


step 2) issue #38 is solved


and what will be that "timeline" in which these features can be reasonably implemented

Question and answer environments produce XeLaTeX errors

Using the following example mark up from the README.adoc file produces errors when the tex output is processed with XeLaTeX.

  [env.question]
  --
  What is the speed of light?
  --

  [click.answer]
  --
  300,000 km/sec
  --

The resulting error is summarised by the following output.

! LaTeX Error: Environment question undefined.

and

! LaTeX Error: Environment answer* undefined.

Can't generate new doctest test

Hi @jirutka , am trying to get back to writing a test suite for asciidoctor-latex.

In /asciidoctor-latex/test/examples/adoc I have the file env.adoc with contents

== Env test

[env.theorem]
--
The equation $a^2 + b^2  = c^2$
has infinitely many non-proportional
integer solutions.
--

When I try to generate a test for this example, I get the following error:

$ bundle exec rake generate PATTERN='env:*' 
(in /Users/carlson/dev/git/asciidoctor-latex)
rake aborted!
Don't know how to build task 'generate'

In Rakefile there is the text

 namespace :generate do
    DocTest::GeneratorTask.new(:latex) do |t|
      t.converter_opts[:backend_name] = :latex
      t.output_suite = DocTest::Latex::ExamplesSuite.new(examples_path: 'test/examples/tex')
      t.examples_path.unshift 'test/examples/adoc'  # extra input examples
    end

    DocTest::GeneratorTask.new(:html) do |t|
      t.converter_opts[:backend_name] = :html
      t.output_suite = DocTest::HTML::ExamplesSuite.new(examples_path: 'test/examples/html')
      t.examples_path = ['test/examples/asciidoc-html']  # input examples
    end
  end

Should this not be sufficient?

I will need you to remind me how to run just a single test since otherwise the output is overwheming.

BTW, I am in Beijing again -- till May 7 -- even more internet restrictions than before: no Google search or gmail, several things don't work here on noteshare because they use googleapis, which are blocked, and of coure no New York Times, Facebook, or Twitter. I will have to get a VPN to tunnel through the Great Firewall (as it is known here). Thank goodness Github works!

Build local gem for testing

I made one change in the gem spec:

   s.add_runtime_dependency 'asciidoctor', '~> 1.5.0', '>= 1.5.0

-- the >= clause.

Also installed the gem locally. How do I now invoke the gem for testing?

Equation number in LaTeX example does not produce expected result

I am testing the examples in the examples directory, and I notice that the equation number in latex example (eqno-latex.adoc) does not seem to produce the expected result after running asciidoctor-latex -b html5 eqno-latex.adoc. I notice two differences.

  1. The equation number in the rendered equations are absent. It renders to an equation followed by a pair of paren () with no number inside. In HTML source:
<table class="equation_table_style"><tr class="equation_row_style">
<td class="equation_content_style";>
\[
a^2  + b^2 = c^2
\]
</td>
 <td class="equation_number_style">() </td> 
</tr></table>
  1. The reference at the bottom of the file is rendered Note: In equation equation we defined a matrix. In HTML source:
<p>Note:  In <span class='xref'><a href=#eq-matrix>equation equation</a></span> we defined a matrix.</p>

P.S. This is with respect to 1.5.0.17.dev installed from gem install asciidoctor-latex --pre, as instructed in https://github.com/asciidoctor/asciidoctor-latex#31-from-rubygems. I see the same behavior in both Chrome and Safari. Since I am very new to Ruby, I have not been able to test against the latest development version in GitHub yet. (Am I expected to not use the version on RubyGems.org?) Thanks!

List not supported in [env]

I would like to write this kind of defintion with a list of properties, this is not supported but it should I think

[env.definition]                                                                                                                               
--                                                                                                                                             
 stem:[\|.\|] : stem:[E \rightarrow \RR] est une *norme* sur stem:[E] ssi elle vérifie :                                                       
                                                                                                                                               
(N1)::  \[ \left( \| x \| = 0 \right)  \Longrightarrow (x=0) \]                                                                                
                                                                                                                                               
(N2)::  \[\forall\, \lambda\in\RR,\; \forall x\in E, \quad \| \lambda x \|  = |\lambda| \; \| x \| \]                                          
                                                                                                                                               
(N3)::   \[\forall\,  x,y \in E, \quad \| x+ y \| \le \|x \| + \|y\|\]   (inégalité triangulaire)                                              
--  

Decide what to do about sentence spacing

This follows the thread LaTeX back-end and sentence spacing on the discussion list.

LaTeX defaults to the classical pre-typewriter tradition of making the spaces between sentences wider than that between words. This can be turned off with the \frenchspacing command, and perhaps that will be necessary in the end—but many people who use LaTeX prefer the older style, and I wonder whether an AsciiDoctor-to-LaTeX translator will be capable of getting this right.

(This effect is achievable in HTML-based back-ends as well: With CSS, give paragraphs the word-spacing property of [say] 0.25em, then wrap sentences in a <span> with a class whose word-spacing has been set to zero. And perhaps if the LaTeX back-end gets sentence spacing right, an option to do the same in HTML might be appropriate. But I suspect this will be a feature little desired. At any rate…)

TeX uses (approximately) the following heuristic for determining sentence-end: a full-stop preceded by a lower-case letter ends an sentence; preceded by an upper-case letter it does not end a sentence (it’s assumed to be an abbreviation); and punctuation like quotes are skipped over. To override this when needed, LaTeX defines the \@ command. See Will Robertson’s LaTeX Alive: Correct punctuation spaces or the following examples:

J. K. Rowling did not shoot J. R\@.  Kristin Shepard did. 

(The \@ before the full-stop tells LaTeX that this does end the sentence, while the other full-stops after capital letters do not.)

Dr.\@ Frankenstein, how good to see you.  Come on in. 

(The \@ after the full-stop tells LaTeX that this does not end the sentence, although normally full-stops after lower-case letters do.)

(I have added a space to the code to show more clearly where the desired end-of-sentence spaces are, but this is neither needed nor recognized in LaTeX.)

As I wrote above, perhaps the best thing to do—certainly the easiest—would be to have the LaTeX back-end emit the \frenchspacing command, which will turn all this off. But still—is it at all possible to define a (non-disruptive & optional) syntax which will allow the user to make use of this typographical nicety?

Testing

So far all my testing has been informal and file-and-eyeball-based: run a file through the converter and see if the output does what it should. If one knew enough to operate with nodes and strings, there could be a better solution: build a node, apply a method to it, examine the result. Any thoughts on this? If I had an example or two I could probably figure out what to do. Rspec works for me.

A # character raises a latex error

A # character included in latex output produces a latex error. The # character is not special in asciidoc but is special in latex. However the # character is passed to the output verbatim.

An asciidoc file with only a # character produces the following latex output

%% Begin Document %%

\begin{document}
\maketitle
#


\end{document}

Regression: Single quotes are being escaped as HTML entities

When using the latex backend, the resulting .tex file has &#8217; in place of single quotes.

Tested with 1.5.0.11.dev. Did not occur with 1.5.0.8.dev.

You can reproduce with the following document:

= Apostrophe issue

Asciidoctor-LaTeX's new issue.

Can't incorporate asciidoctor-latex into noteshare.io

When I do `$push staging latex2:master, I get the errors appended below. Any idea of what the problem is?

I am forking off from a branch that runs without problems. My goal is use asciidoctor-latex in Noteshare so as to give the former a real field-test.

$ git push --force staging latex2:master
Fetching repository, done.
Counting objects: 90, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (90/90), done.
Writing objects: 100% (90/90), 12.68 KiB | 0 bytes/s, done.
Total 90 (delta 73), reused 0 (delta 0)

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.1.2
-----> Installing dependencies using 1.7.12
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Fetching gem metadata from https://rubygems.org/........
       Fetching git://github.com/asciidoctor/asciidoctor-latex.git
       fatal: Could not parse object '7b51ac42bf78d0bf8a3bc19edd20d4e4e97a0780'.
       Git error: command `git reset --hard 7b51ac42bf78d0bf8a3bc19edd20d4e4e97a0780`
       in directory
       /tmp/build_8cf230bc6d65f4091b41f541ae52c392/vendor/bundle/ruby/2.1.0/bundler/gems/asciidoctor-latex-7b51ac42bf78
       has failed.
       If this error persists you could try removing the cache directory
       '/tmp/build_8cf230bc6d65f4091b41f541ae52c392/vendor/bundle/ruby/2.1.0/cache/bundler/git/asciidoctor-latex-0cd500cc6bcc3aa4515af3dd6d51e84257ee77cf'
       Bundler Output: Fetching gem metadata from https://rubygems.org/........
       Fetching git://github.com/asciidoctor/asciidoctor-latex.git
       fatal: Could not parse object '7b51ac42bf78d0bf8a3bc19edd20d4e4e97a0780'.
       Git error: command `git reset --hard 7b51ac42bf78d0bf8a3bc19edd20d4e4e97a0780`
       in directory
       /tmp/build_8cf230bc6d65f4091b41f541ae52c392/vendor/bundle/ruby/2.1.0/bundler/gems/asciidoctor-latex-7b51ac42bf78
       has failed.
       If this error persists you could try removing the cache directory
       '/tmp/build_8cf230bc6d65f4091b41f541ae52c392/vendor/bundle/ruby/2.1.0/cache/bundler/git/asciidoctor-latex-0cd500cc6bcc3aa4515af3dd6d51e84257ee77cf'
 !
 !     Failed to install gems via Bundler.
 !

 !     Push rejected, failed to compile Ruby app

To [email protected]:gentility.git
 ! [remote rejected] latex2 -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:gentility.git'

asciidoctor-latex - undefined method gsub

I'm submitting that at the suggestion of Dan Allen (quoted below).

Main discussion of this issue is here:
(http://discuss.asciidoctor.org/asciidoctor-latex-undefined-method-gsub-td5752.html#a5754)

"I see the problem now. Asciidoctor LaTeX is assuming that the reference text is not nil. However, since Asciidoctor 1.5.6(.1), the converter is now responsible for providing a fallback value. So the LaTeX converter needs to check for a nil value. Can you report this in the Asciidoctor LaTeX project?"

The test file was called x.adoc in the main discussion. Wasn't allowed to use that name here.
test-file.txt

Conrad

support embedding [env] within other [env]

@jxxcarlson it would be nice to be able to embed [env] within [env]
for example you may want to have nice equations using [env.equation] within a [env.theorem]

here is an example

[env.theorem#thr:14]
--
Soit stem:[T_K] une transformation affine.

Soit stem:[\mathbb{P}_k \subset \hat{P}] et stem:[k+1 > \frac{d}{2}].

Soit stem:[h_K] le diamètre de stem:[K] et stem:[\rho_K] le diamètre de la plus grande boule inscrite dans stem:[K] et stem:[\omega_K = \frac{h_K}{\rho_K}].

Alors il existe une constante stem:[c] independente de stem:[K] telle que stem:[\forall v \in H^{k+1}(K)] et pour tout stem:[m \in \{0,...,k+1\}],

[[eq:32]]
\[
  |v - \Ilag{K}(v)|_{m,K} \leq  c h^{k+1-m} \omega_K^m |v|_{k+1,K}
\]
--

I would like for example to have [eq:32] to be a [env.equation] but that's not possible

Question - prepend processor - @mojavelinux

@mojavelinux, I am working on a PrependProcessor,
but have run into another wall. The PrependProcessor "works",
but instead of giving me what I want, it adds everything I have
to the first line of the file begin processed. I do find this
(log output from PrependProcessor in running the test"

   BEGIN: reader.lines 40
   END:   reader.lines 43

I've tried various line-ending
combinations ("\n", "\r") to no avail. I must be missing something.
Here ite code:

class PrependProcessor < Extensions::Preprocessor

  def process document, reader
    return reader if reader.eof?
    puts "BEGIN: reader.lines #{reader.lines.count}".yellow

    lines_to_prepend = []
    lines_to_prepend << "He took his vorpal sword in hand\n"
    lines_to_prepend << "Long time the manxome foe he sought\r" 
    lines_to_prepend << "La di dah doo day\n"

    reader.unshift_lines lines_to_prepend
    puts "END:   reader.lines #{reader.lines.count}".yellow
    reader
  end

end

I need the above to insert things like the below, which for the moment I do manually.
This one is needed to make [click.solution], [click.objection], etc., work.

++++

<style>
.click .title { color: blue; }
// .click .content { font-style: oblique; }
</style>

<script src="js/jquery.js"></script>

<script>    
    $(document).ready(function(){                                      
      $('.openblock.click').click( function()  { $(this).find('.content').slideToggle('200') }  )  
      $('.openblock.click').find('.content').hide()   
    });
</script>

++++

PSS

  1. Will remove all puts lines or turn in to warn .. if $VERBOSE when I do the PR.
  2. I intend lo load the js over the net from Google, but can't do that now -- Google is blocked in China.

Percent sign % is not escaped in output latex

The following adoc trigger the problem:

== Percent sign is not escaped

[quote]
House prices will rise by 30% in five years

In the produced latex file the % is not escaped and it will generate an error.

If we in the latex file the '%' is substituted manualy with '%' everything works fine. Thank you

Multiple math mode glitches

It looks like \[\] equation environment is very glitch if it is placed in the middle of a line, and sometimes weird + signs will appear. Looks like an incorrectly inserted new line to me.

Another glitch is that a closing square bracket can end up outside the math if $...$ is used for mathmode, but this is not a problem with \(\).

Use doctest for tests

@jirutka, could you add one doctest for latex, one for html? I could use this as a template for developing a reasonable test suite. I think this is one of our main priorities.

`macros.tex` ignored when using HTML backend

The README states:

The contents of a file named macros.tex will be read and used by asciidoctor-latex if it is in the same directory as the file being rendered. This is the case regardless of the output format -- HTML or tex.

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:

= Basic document

This is just to show that `macros.tex` isn't being used for the HTML output.

In the same directory, create a macros.tex file:

\dummymacro

Latex backend: no problem

Do:

asciidoctor-latex test.adoc

The command \dummymacro shows up in the preamble of test.tex, under the line %User defined macros.

Html backed: no macro

Do:

asciidoctor-latex -b html test.adoc

The string dummymacro in test.html is nowhere to be found.

Add style sheet?

Is there a way to package a CSS style sheet with the distribution of Asciidoctor-latex? This would be a small file that would be loaded after the main Asciidoctor CSS file.

Map open blocks to environments explicitly

I like the idea of auto-creating LaTeX environments. However, I would be much more comfortable if the environment name was marked explicitly rather than overloading the use of the block title as it would be more in spirit with the extension model in AsciiDoc.

Something like:

[env=foo]
--
blah blah blah
--

You could then retrieve the environment from the attributes map.

Other idea is to dedicate the block name "env" for this purpose and then it would be more reasonable to reuse the title since the association is now explicit.

[env]
.foo
--
blah blah blah
--

Or, instead of the title, you could make it the first role. In my mind, role maps best for this scenario:

[env.foo]
--
blah blah blah
--

This second approach would require registering an extension as part of the converter.

Error: Only book doctypes can contain level 0 sections

Hi, a question:

If I use this diff

diff --git a/try-out/eqno-latex.adoc b/try-out/eqno-latex.adoc
index c98e741..207e51f 100644
--- a/try-out/eqno-latex.adoc
+++ b/try-out/eqno-latex.adoc
@@ -1,5 +1,6 @@
-== Numbered Equations
+= Numbered Equations

+== Something

 The environment `[env.equation]` is automatically
 numbered by default, as in the examples below.

that changes the == heading to a =, and run with asciidoctor -b html5 -r asciidoctor-latex --attribute=stem=latexmath --backend=html eqno-latex.adoc, then I get

asciidoctor: ERROR: eqno-latex.adoc: line 1: only book doctypes can contain level 0 sections

This only happens with the html backend, with the latex backend everything is fine.

What's going on here?

dollar signs in source blocks

It seems asciidoctor-latex currently parses the content of a source block. The following example shows their interaction.

foo.adoc:

= Include Bug Demo

Testing $x$, $y$.

[source,perl]
----
print $_, $_;
----

EOF

The output for the source block is:

print pass:[\(_, \)]_;

This seems counterintuitive since we may expect that a source block to be processed only by a source highlighter. While we may expect the writer to alter the code in a source block to escape the dollar signs and thus this interaction may be acceptable, this interaction effectively prohibits the use of include, (e.g., include::bar.pl[]).

On the expression $ .. $

(1) When we have the new parser, let's see if in latex mode we can parse /$.*$/m as an "inline-latex-expression" or some such. That is, text beginning and ending with $ would be so parsed even
if it extended over a line break. This would prevent a common rendering error in Asciidoctor-LaTeX where there is such a line break.

(2) I suggest that the switch / attribute for using $ as a delimiter be :latex: (Then when talking money,
one must say \$100).

(3) With :latex: on, there are other conventions to be followed, e.g., (a) \_ for _, (b) \% for %,
(c) \& for &. I'll compile a list of these and I welcome help on it!

Convert stem, asciimath to latex format

@mojavelinux or @jirutka, I have a question. In order to convert stem, asciimath input to LaTeX, I need to call something in the core to do the conversion for the LaTeX backend. For example, I need to map sqrt(2) to \sqrt(2). There must be something in the core that does this, so all I would need to do is call the right method on node.content go get the converted text. Could you tell me how to do this.

Latex errors for documents with HTML encoded characters

Asciidoctor documents that contain characters that would get encoded in HTML (f.ex. & -> &amp;) will produce an error when converted to LaTeX and compiled.

Example test.adoc:

Hello & world

Convert it to LaTeX and compile it:

$ asciidoctor -r asciidoctor-latex/converter.rb -b latex test.adoc
$ pdflatex test.tex

LaTeX Error:

! Misplaced alignment tab character &.
l.96 Hello &
       amp; world

It would be cool if asciidoctor-latex could replace the HTML () encodings.

Special characters in LaTeX: http://en.wikibooks.org/wiki/LaTeX/Special_Characters

Monospace with \texttt instead of \tt

I'm having a problem with monospace. I'm not a latex expect, but when I try to compile a document with monospace I end up with an error.

Let's see how it is implemented:

$ echo "\`monospace\` _italic_ *bold*" | asciidoctor-latex -a header=no -

The result was:

{\tt monospace} \emph{italic} \textbf{bold}

I propose to change {\tt monospace} to \texttt{monospace} (works for me).

The \texttt is documented at https://en.wikibooks.org/wiki/LaTeX/Fonts

Set counter for [env.*]

I'd like to set the counter used to number theorems, etc by something like

   [env.theorem, counter=43]

I can access the value 43 in the example above via attrs['counter]. so I'd lke to do something like

caption_num = parent.document.counter("#{env_ref_prefix}-number", attrs['counter'].to_i)

However, this doesn't work.

per https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/document.rb#L485. Note tha I use the real counter in https://github.com/asciidoctor/asciidoctor-latex/blob/master/lib/asciidoctor/latex/environment_block.rb#L159 as

https://github.com/asciidoctor/asciidoctor-latex/blob/master/lib/asciidoctor/latex/environment_block.rb#L159

[stem] and [env.equation] have differences, [env.equation] seems to support less

Hi

[stem]
+++
+++

and

[env.equation]
--
--

don' t seem to support the same latex command and [env.equation] seems to support less latex than [stem]

[env.equation]
.Momentum conservation equation
--
\rho_{f} \left. \frac{\partial\mathbf{u}_f}{\partial t} \right|_\mathrm{x}
+ \rho_{f} \left( \boldsymbol{u}_{f} \cdot \nabla_{\mathrm{x}} \right) \boldsymbol{u}_{f}
- \nabla_{\mathrm{x}} \cdot \boldsymbol{\sigma}_{f} = \boldsymbol{f}^t_f , \quad \text{ in } \Omega^t_f \times \left[t_i,t_f \right]
--

[stem]
++++
\rho_{f} \left. \frac{\partial\mathbf{u}_f}{\partial t} \right|_\mathrm{x}
+ \rho_{f} \left( \boldsymbol{u}_{f} \cdot \nabla_{\mathrm{x}} \right) \boldsymbol{u}_{f}
- \nabla_{\mathrm{x}} \cdot \boldsymbol{\sigma}_{f} = \boldsymbol{f}^t_f , \quad \text{ in } \Omega^t_f \times \left[t_i,t_f \right]
++++

attached the rendered math, above with [env.equation] fails while there are no problem with [stem]

any idea ?

screenshot 2017-02-23 06 04 35

Bad character substitutions

I have a file in which

\[
   (yx'^2)^2 = x'g(x')
\]

maps to

\[
  y^2 = \frac{x�g(x')}{x'^4}
\]

Also,

[env.equation]
--
y'^2 = x'g(x')
--

maps to

\begin{equation}
y'^2 = x�g(x')
\end{equation}

These should be the identity transformations ... any suggestions on how best to
handle this?

Proposal to promote project to asciidoctor-latex-plus

I'd like to propose that this project be promoted (i.e., renamed) to asciidoctor-latex-plus. I support the idea of improvising on the AsciiDoc syntax to create a dialect that appeals to a more LaTeX-minded audience, and I certainly want to encourage that innovation. However, I'm concerned that by calling it asciidoctor-latex, we've left a gap for the user seeking a faithful conversion of vanilla AsciiDoc to LaTeX. LaTeX is a very important format in this toolchain and we want to do the basics well.

By renaming the project to asciidoctor-latex-plus, it leaves room for a more "plain Jane" asciidoctor-latex converter. This converter would use as few LaTeX packages as possible and only convert standard blocks to their LaTeX equivalent. I envision it building on the manpage converter in core, which is going to provide a useful starting point as it produces output in the same markup family (non-XML). (There would be no HTML output in asciidoctor-latex).

It may even happen that asciidoctor-latex-plus eventually builds on asciidoctor-latex, no longer having to worry about converting the basic elements. Instead, it can focus on the extended elements. In that regard, I think it will make more room for creativity to flourish in asciidoctor-latex-plus.

If there's agreement with this proposal, I'd be happy to help set up the two projects and get the ball rolling. I'd be looking for someone who is interested in completing the converter and also someone to maintain it. (My one request is that we have good tests for it).

Latex2Asciidoctor

I've started roughing out a converter for LaTeX to Asciidoctor -- for the moment working on
a very rough recursive descent parser for a coarse-grained version of LaTeX, which is all that will
be needed in the way of LaTeX parsers. For the moment it is not very recursive. but once I am
confident of what I am doing now, I will update the grammar to make it more so.

@mojavelinux, if you have any suggestions on this, that would be great, since I am just starting
and it is now easy to change course. Also, did you see your gmail account? I will be in Denver
Feb 9, arriving at 10:30 am, leaving the next morning for Boulder and Fort Collins. Would you
have time for a quick bite or a drink?

The repo is at https://github.com/jxxcarlson/latex2asciidoctor

(( I will update the README this evening to give an idea of what the current structure is,
what it currently does, and what it should do. ))

On Reserved Characters and the Two-Universe Problem

One of the thorny issues with the LaTeX backend for Asciidoctor is what to do
with characters such as $, &, _ and a few others. The first plays a spacial role
in the LaTeX universe as a delimiter for mathematical expressions, e.g.
$(a^2)^3 = 1$. In the universe we normally inhabit, it is for US dollars. (Ahem,
and bash?)

The problem is that these two universes are not entirely separate. I've been trying
to handle the conflicts with various hacks. Now, however, I have
a large set of documents "from the wild" on which to apply the converter, and realized that it is probably
best to enforce a separation:

  1. Asciidoc documents will treat symbols like $, &, _ as normal people do.
    That means that they will be escaped by Asciidotor before being sent into the gullet
    of the Asciidoctor-LaTeX converter. The result should be reliable conversoin to LaTeX
    for those who want it. It is also a route to getting PDF. That said, Asciidoctor's HTML
    format is more pleasing to the eye.
  2. Documents written in Asciidoctor-LaTeX will treat symbols like $,&, _ according to
    the rules of the LaTeX universe. This means that the user must escape these
    symbols if they are to have their conventional meaning. Mathematicians and other
    LaTeX users are used to doing this, so this should not cause any sociological problems.
  3. One has to be liberal about interpreting 1) vs (2). Asciidoctor-LaTeX's [env.FOO] feature can be quite handy for authors that never write an equation. The main point of distinction is the presence of
    mathematical text.

Noteshare can do a fairly good job of auto-detection of the universe in which the author
is operating, but i think the default is just to have an attribute which decides the issue.
Thus a law office using Asciidoctor-LaTeX would not set that attribute and lawyerly documents
will convert as expected, and ditto for, say, docs with code but no math. We leave the burden
of setting the attribute on those who need it the most.

The name of the attribute should not be :latex: since that would be confusing -- the user
is already using Ascidoctor-LaTeX.

@mojavelinux, @jirutka , all, I would appreciate your comments before proceedidng.

Prepend hack

@mojavelinux, @Mogztter , @jirutka -- if you have a chance, could you look at the prepend-hack2 branch of asciidoctor-latex? This is a proposed workaround to avoid Ruby 2.0 prepend, based on
@mojavelinex's code. It seems to me that in this case one does not have to remove methods before including the Html5ConverterExtensions module.

I've only done one test, but it seems to work. It this is indeed the case, then the road is open for Chrome extension, Atom, etc., to support asciidoctor-latex. For us mathematicians, that would be awesome indeed.

I will do more testing.
PS. @jirutka: ping!

Negative line number reported in output messages

I am using 652176e with asciidoctor bd8927b (both latest as of this writing).

First, create two files:

  1. foo.adoc
= Negative line number

include::bar.adoc[]
  1. bar.adoc
== A

==== B

b

==== C

c

Then run asciidoctor-latex foo.adoc. The output says:

asciidoctor: WARNING: foo.adoc: line -3: section title out of sequence: expected level 2, got level 3
asciidoctor: WARNING: foo.adoc: line 1: section title out of sequence: expected level 2, got level 3

Prevent substitutions for certain sequences on which LaTeX chokes

The following characters or sequences of characters are mapped to entities which cause LaTeX
to choke (pdflatex crashes or misbehaves), xelatex proceeds, but leaves ugly entity traces in the rendered output.

The list:

--, which maps to  — 
' (apostrophe), which maps to &#8217
> which maps to &gt;
< which mspd to &lt;

I will add to this as I test more docs.

For the moment I run the output of asciidoctor-latex-converter through the filter below before running latex:

cat foo.tex | sed 's/&#8201;&#8212;&#8201;/--/g' | sed "s/&#8217/'/g" | sed 's/&gt;/>/g' | sed 's/&lt;/</g' > foo2.tex

Better way of adding alternate style sheets

Currently the style sheet data/extras.css is added by default using the code in css.rb via
class CSSDocinfoProcessor as suggested by @mojavelinux . I need to append the text in the tail of
data/extras_print_version.css. At the moment I do something stupid: if
doc.attributes['print_format'] == yes, the stylesheet extras_print_version.css is loaded, otherwise
extras.css is. A quick, dirty, BAD solution. Suggestions? Is there a way of modifying extras.css on the fly?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.