fletcher / MultiMarkdown-6

Lightweight markup processor to produce HTML, LaTeX, and more.
https://fletcher.github.io/MultiMarkdown-6/
Other
628 stars 90 forks source link

Metadata ( -m ) retuns (null) in command line #78

Closed nanov closed 7 years ago

nanov commented 7 years ago

MMD v 6.10, when I execute multimarkdown with the -m parameter i get just (null), am I getting something wrong, or is it intended?

fletcher commented 7 years ago

Does your document have any metadata in it?

nanov commented 7 years ago

Of course :) I have also tried also with this one, result is the same...

fletcher commented 7 years ago

Use the develop branch.

nanov commented 7 years ago

Still the same behavior

fletcher commented 7 years ago

It works fine for me (using the file you linked to above):

[minime:5 - Maintenance/mmd6-public/build] fletcher% ./multimarkdown -m test.txt 
title
css
htmlheader
latexleader
latexbegin
latexfooter
foo
foo
htmlheaderlevel
latexheaderlevel
baseheaderlevel
djr555 commented 7 years ago

multimarkdown -m test.txt works fine for me if test.txt contains metadata but returns (null) without a return character if there is no metadata. I might have expected no output if nothing if found.

Also, multimarkdown -e metadata test.txtworks as expected if metadata is found but fails when not found.

donald$ multimarkdown -e css test.txt
http://foo.com/bar.css
donald$ multimarkdown -e nothing test.txt
Segmentation fault: 11

Maybe no output and an error code to stderr would be a more consistent and graceful result for each of these cases.

fletcher commented 7 years ago

Fixed in develop.

Thanks!

djr555 commented 7 years ago

Hi Fletcher,

Thanks for the fast response and fix.

I am not a programmer but wonder, since you are so meticulous about releasing memory, whether it would be better to put the free(char_result) outside the if clause. ((Line 422 and line 434 of main.c in develop branch)

Background I have used multimarkdown markup for several years but have almost exclusively used Marked(2) to display the result, with adequate results. Now that Composer is being redeveloped/enhanced I am keen to move on to using it instead. This led me to revisit your multimarkdown program and I have had a few issues getting it to match the output you provide for QuickStart.txt. Since the pdf output requires the mmd2pdf script, I encountered the metadata error on the way to understanding the \latextitle error I first raised. When I work around that I next run into the tufte-handout error involving \MakeTextLowercase in tufte-common.def which nobody seems to have resolved. This is strange as I have used tufte-handout before without issue. Maybe different programs (e.g. TeXnicle) just skip minor errors and move on.

Regards,

Donald

On 20170821, at 12:59 am, Fletcher T. Penney notifications@github.com wrote:

Fixed in develop.

Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fletcher/MultiMarkdown-6/issues/78#issuecomment-323590352, or mute the thread https://github.com/notifications/unsubscribe-auth/AFUuEsaK1Yu0EOLVJqLscHvQ38wT9W9Wks5saEnQgaJpZM4OwQtP.

fletcher commented 7 years ago

Why free memory if it wasn't allocated? The only reason the if clause would not be traversed is if char_result is NULL, in which case it doesn't need to be freed.

Right?

mmd2pdf is a useful shortcut if everything is exactly right. LaTeX is a complex program, to say the least, and things rarely work exactly right the first time. I recommend creating PDFs "manually" until you're confident in your workflow. I use latexmk when creating pdf's -- I almost never use mmd2pdf.

djr555 commented 7 years ago

I knew it was unwise for me to comment on code since I haven’t written C (or anything much else) for over 30 years!

Nevertheless: Dare I suggest that mmd6-tufte-handout-leader.tex and mmd6-tufte-book-leader.tex would benefit from the inclusion of mm6-title.tex before mmd6-default-metadata.tex is input. Maybe it could go inside mmd6-default-metadata.tex, above the existing code, but I see it is called in mmd6-article-begin.tex, which is after mmd6-default-metadata in this case. Presumably, \myauthor and \mytitle get overwritten with “Author” and “Title” respectively.

% Configure default metadata to avoid errors \input{mmd6-title} \input{mmd6-default-metadata}

This stops the following error when there is no latex title metadata.

Writing index file QuickStart.idx (/Users/donald/Library/texmf/tex/latex/mmd6/shared/mmd6-default-metadata.tex)) (/Users/donald/Library/texmf/tex/latex/mmd6/tufte-handout/mmd6-tufte-handout-be gin.tex /Users/donald/Library/texmf/tex/latex/mmd6/tufte-handout/mmd6-tufte-handout-beg in.tex:3: Undefined control sequence.

\latextitle l.3 \title{\latextitle} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., `\hobx'), type `I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined. Donald > On 20170821, at 11:04 am, Fletcher T. Penney wrote: > > Why free memory if it wasn't allocated? The only reason the if clause would not be traversed is if char_result is NULL, in which case it doesn't need to be freed. > > Right? > > mmd2pdf is a useful shortcut if everything is exactly right. LaTeX is a complex program, to say the least, and things rarely work exactly right the first time. I recommend creating PDFs "manually" until you're confident in your workflow. I use latexmk when creating pdf's -- I almost never use mmd2pdf. > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub , or mute the thread . >
fletcher commented 7 years ago

Are you sure you've installed the latest versions of the latex support files? The following works just fine for me:

Title:  MultiMarkdown v6 Quick Start Guide
Author: Fletcher T. Penney
Version:    6.1.0
LaTeX Config:   tufte-handout
Base Header Level:  3

# Test #

Hi.
djr555 commented 7 years ago

I am seriously confused. I have copied the mmd6 support files from the Master branch (again) but still can't get your minimal example to compile to PDF. The tex file is as expected:

\input{mmd6-tufte-handout-leader}
\def\mytitle{MultiMarkdown v6 Quick Start Guide}
\def\myauthor{Fletcher T. Penney}
\def\version{6.1.0}
\input{mmd6-tufte-handout-begin}

\section{Test }
\label{test}

\input{mmd6-tufte-handout-footer}
\end{document}

but this fails in pdfTex with:

/Users/donald/Library/texmf/tex/latex/mmd6/tufte-handout/mmd6-tufte-handout-beg
in.tex:12: Undefined control sequence.
\@title ->\latextitle 

l.12 \maketitle

I expect this to fail since \latextitle is only defined in mmd6-title.tex, which is only referenced in mmd6-article-begin.tex and nowhere else. So \latextitle is never set in the support files when using tufte-handout or tufte-book, although it is set inside latex.c if and only if the latex title metadata is used.

Donalds-iMac:mmd6 donald$ pwd
/Users/donald/Library/texmf/tex/latex/mmd6
Donalds-iMac:mmd6 donald$ ls -l
total 0
drwxr-xr-x@  5 donald  staff  170 15 Aug 10:19 article
drwxr-xr-x@  7 donald  staff  238 15 Aug 10:19 letterhead
drwxr-xr-x@ 10 donald  staff  340 15 Aug 10:19 shared
drwxr-xr-x@  5 donald  staff  170 15 Aug 10:19 tufte-book
drwxr-xr-x@  5 donald  staff  170 15 Aug 10:19 tufte-handout
Donalds-iMac:mmd6 donald$
Donalds-iMac:mmd6 donald$ grep 'latextitle' */*
article/mmd6-article-begin.tex:\title{\latextitle}
shared/mmd6-title.tex:\ifx\latextitle\undefined
shared/mmd6-title.tex:  \def\latextitle{\mytitle}
tufte-book/mmd6-tufte-book-begin.tex:\title{\latextitle}
tufte-handout/mmd6-tufte-handout-begin.tex:\title{\latextitle}
Donalds-iMac:mmd6 donald$
Donalds-iMac:mmd6 donald$ grep 'mmd6-title' */*
article/mmd6-article-begin.tex:\input{mmd6-title} 

Since I cannot get a simple example to work, I feel that I should leave this to more experienced people to resolve, assuming they encounter they same problem.

Thanks anyway for your responses to my questions.

fletcher commented 7 years ago

I checked again -- looks like the last changes I made were not pushed to github, and only existed in my own texmf folder.

When I was working on it, one problem that arose was related to some trickiness with concatenating fields....

Try adding \input{mmd6-title} to beginning of mmd6-tufte-book-begin.tex and mmd6-tufte-handout-begin.tex.

Otherwise, I had to do some craziness in mmd6-title.tex.... Convert each instance of \addtodef{\myauthor}{}{ \\ ...} to \expandafter\defexpandafter\myauthor\expandafter{\myauthor \\ ...}.

It seems to work for me, but might need more testing.