protected override void Write(LatexRenderer renderer, MathBlock obj)
 {
     renderer.EnsureLine();
     renderer.WriteLine("\\begin{equation*}");
     renderer.WriteLeafRawLines(obj, true, false);
     renderer.WriteLine("\\end{equation*}").WriteLine();
 }
Beispiel #2
0
        protected override void Write(LatexRenderer renderer, QuoteBlock obj)
        {
            renderer.EnsureLine();
            renderer.Write(@"\begin{quote}") /*.WriteAttributes(obj).WriteLine(">")*/;
            var savedImplicitParagraph = renderer.ImplicitParagraph;

            renderer.ImplicitParagraph = false;
            renderer.WriteChildren(obj);
            renderer.ImplicitParagraph = savedImplicitParagraph;
            renderer.WriteLine(@"\end{quote}");
        }
Beispiel #3
0
 protected override void Write(LatexRenderer renderer, ParagraphBlock obj)
 {
     if (!renderer.ImplicitParagraph)
     {
         if (!renderer.IsFirstInContainer)
         {
             renderer.EnsureLine();
         }
         //renderer.Write("\n")/*.WriteAttributes(obj).Write(">")*/;
     }
     renderer.WriteLeafInline(obj);
     if (!renderer.ImplicitParagraph)
     {
         renderer.Write("\n");
         //renderer.WriteLine("</p>");
     }
 }
Beispiel #4
0
        protected override void Write(LatexRenderer renderer, ListBlock listBlock)
        {
            renderer.EnsureLine();
            if (listBlock.IsOrdered)
            {
                renderer.Write("\\begin{enumerate}\n");
                //if (listBlock.BulletType != '1')
                //{
                //    renderer.Write(" type=\"").Write(listBlock.BulletType).Write("\"");
                //}

                //if (listBlock.OrderedStart != null && (listBlock.OrderedStart != "1"))
                //{
                //    renderer.Write(" start=\"").Write(listBlock.OrderedStart).Write("\"");
                //}
                //renderer.WriteAttributes(listBlock);
                //renderer.WriteLine(">");
            }
            else
            {
                renderer.Write("\\begin{itemize}\n");
                //renderer.WriteAttributes(listBlock);
                //renderer.WriteLine(">");
            }
            foreach (var item in listBlock)
            {
                var listItem         = (ListItemBlock)item;
                var previousImplicit = renderer.ImplicitParagraph;
                renderer.ImplicitParagraph = !listBlock.IsLoose;

                //renderer.EnsureLine();
                renderer.Write(@"    \item ") /*.WriteAttributes(listItem).Write("]")*/;
                renderer.WriteChildren(listItem);
                renderer.WriteLine();

                renderer.ImplicitParagraph = previousImplicit;
            }
            renderer.WriteLine(listBlock.IsOrdered ? "\\end{enumerate}" : "\\end{itemize}");
        }
Beispiel #5
0
        protected override void Write(LatexRenderer renderer, CodeBlock obj)
        {
            renderer.EnsureLine();
            var fencedCodeBlock = obj as FencedCodeBlock;

            if (fencedCodeBlock != null)
            {
                var info     = fencedCodeBlock.Info ?? string.Empty;
                var langFrag = info.Split(':');

                var language = langFrag[0];
                var label    = langFrag.Length > 1 ? langFrag[1] : null;
                var caption  = langFrag.Length > 2 ? langFrag[2] : null;

                var hasOptions = false;

                renderer.Write("\\begin{lstlisting}[");
                if (!String.IsNullOrEmpty(language))
                {
                    renderer.Write("language=");
                    renderer.Write(language);
                    hasOptions = true;
                }
                if (label != null)
                {
                    if (hasOptions)
                    {
                        renderer.Write(",");
                    }
                    renderer.Write("label=");
                    renderer.Write(label);
                    hasOptions = true;
                }
                if (caption != null)
                {
                    if (hasOptions)
                    {
                        renderer.Write(",");
                    }
                    renderer.Write("caption=");
                    renderer.Write(caption);
                }
                renderer.Write("]\n");

                renderer.WriteLeafRawLines(obj, true, true, true);

                renderer.Write("\\end{lstlisting}");
            }

            //if (fencedCodeBlock?.Info != null && BlocksAsDiv.Contains(fencedCodeBlock.Info))
            //{
            //    var infoPrefix = (obj.Parser as FencedCodeBlockParser)?.InfoPrefix ??
            //                     FencedCodeBlockParser.DefaultInfoPrefix;

            //    // We are replacing the HTML attribute `language-mylang` by `mylang` only for a div block
            //    // NOTE that we are allocating a closure here
            //    renderer.Write("<div")
            //        .WriteAttributes(obj.TryGetAttributes(),
            //            cls => cls.StartsWith(infoPrefix) ? cls.Substring(infoPrefix.Length) : cls)
            //        .Write(">");
            //    renderer.WriteLeafRawLines(obj, true, true, true);
            //    renderer.WriteLine("</div>");

            //}
            //else
            //{
            //    renderer.Write("<pre");
            //    if (OutputAttributesOnPre)
            //    {
            //        renderer.WriteAttributes(obj);
            //    }
            //    renderer.Write("><code");
            //    if (!OutputAttributesOnPre)
            //    {
            //        renderer.WriteAttributes(obj);
            //    }
            //    renderer.Write(">");
            //    renderer.WriteLeafRawLines(obj, true, true);
            //    renderer.WriteLine("</code></pre>");
            //}
        }