Write a Markdown - Latex converter The NetBSD Project
Status: Closed Time to complete: 192 hrs Mentors: Julian Coleman, Julian Fagir Tags: C, Latex, research, wiki, ui

This task is not strictly for NetBSD, but another project named libsoldout: http://fossil.instinctive.eu/libsoldout/index

libsoldout is a markdown converter written in C and published under public domain. Though there are already other tools which would do this task, they either have a licence that is not usable by NetBSD or have too many dependencies (like pandoc).
Your task is to write a converter from Markdown to Latex (or PDF, which might be a fairly large task and not suited for Code-In), which is just specifying some tags you use for inserting and putting it in C code.


You can take the html or the mdoc converter as a template for this:

http://fossil.instinctive.eu/libsoldout/artifact/fd100c723c722189d62fd9bf261d67db69240043 and http://fossil.instinctive.eu/libsoldout/artifact/1e22b7962dfba92c28f4916609746045dbe29a90 respectively. 

Though this task seems large, the task itself is rather small. You have to analyze the converters for mdoc and html and replace their tags by the appropriate Latex ones.
If you're not as good with Latex, feel free to ask for the tags that are to replace. Latex is not a strict prerequisite!

Uploaded Work
File name/URL File size Date submitted
mkd2latex.zip 4.5 KB November 27 2012 10:55 UTC
mkd2latex escapier.zip 4.6 KB November 28 2012 05:26 UTC
mkd2latex prolog epilog.zip 4.6 KB November 29 2012 05:08 UTC
Comments
Task Claimed by fernozzle November 27 2012 06:30 UTC

I would like to work on this task.

Task Assigned by Aleksej Saushev November 27 2012 08:22 UTC

This task has been assigned to fernozzle. You have 192 hours to complete this task, good luck!

Ready for review by fernozzle November 27 2012 10:56 UTC

The work on this task is ready to be reviewed.

Task Needs More Work by Julian Coleman November 27 2012 11:10 UTC

One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.

mkd2latex.zip needs more work by Julian Coleman November 27 2012 11:20 UTC

Hi,


I downloaded the zip and tried to build the prgram with:


  make -f BSDMakefile


However, it did not build.  Please could you include some instructions on how to build and run the program, and maybe also a small example file that it will convert?


Thanks,


J


 

It is a plugin by gnrp November 27 2012 11:54 UTC

Hi,


this is a plugin for the libsoldout program. I will check this task later on.


Regards, Julian 

The zip only contains the files that I changed by fernozzle November 27 2012 14:52 UTC

Sorry, the zip only contains the files that I changed from those of libsoldout.

The changes that I made by fernozzle November 27 2012 17:01 UTC

Sorry, the changes that I mentioned are that I created mkd2latex.c and I added tgat it to the makefiles.

"tgat" (typo) by fernozzle November 27 2012 17:07 UTC

Whoops. "tgat" is supposed to be "that", and it's supposed to go before "added".

Very nice, just some small things by gnrp November 27 2012 17:35 UTC

Hi,


actually, this is very nice. I didn't expect the task to be solved that fast and that nice!


There are just a few quirks:



  • Please document somewhere which packages are needed (e.g. hyperref must be included in the document)

  • Some characters must be escaped. I just tried a random document from the NetBSD wiki and there were several underscores and dollar signs which had to be escaped manually (I think this was inside a texttt environment).


Regards, Julian 

Noticing the author by gnrp November 27 2012 17:46 UTC

Hi,


just one more task that would be nice: Contact the author of libsoldout with a link to this work, you can find her e-mail address and gpg key here:


    http://wwwkeys.pgp.net:11371/pks/lookup?op=index&search=0x69277CC1


I think she will be glad to see more projects spawning from her own one.


If you don't want to do so, but you permit others to use your code (I suppose so after the licence I read), I can do this as well. 


Regards, Julian 

How should I document which packages are needed? by fernozzle November 27 2012 23:56 UTC

Thanks.


How would you like me to document which packages are needed? I'm not sure where they shoud be documented.

*should by fernozzle November 28 2012 00:11 UTC

*should


Also, I do not want to contact her. I am a lowly student!

Documentation and contact by gnrp November 28 2012 00:14 UTC

Hi,


if you do not want to contact her, that's not a problem. She will be poked to this program anyway.


If you don't need more than hyperref, you don't have to care for the documentation. Except for escaping invalid characters in environments as underscores and dollar signs, you're fine with your written program.


Regards, Julian 

graphicx package by fernozzle November 28 2012 00:38 UTC

I need to require the graphicx package for images!

Ready for review by fernozzle November 28 2012 05:26 UTC

The work on this task is ready to be reviewed.

New version, now with improved escaping by fernozzle November 28 2012 05:32 UTC

It's a little difficult for me to tell what rendering function's calling what  so that I don't escape characters multiple times — (and what LaTeX commands require escaping and what don't), but hopefully this new revision (named "mkd2latex escapier.zip") solves the problems of \texttt not being escaped.


Thanks!

Problems analyzed by gnrp November 28 2012 14:33 UTC

Hi,


Ok, just two final things, then this task is done: 



  • please escape only in normal_text, code_block and code_span.



  • please create hooks for  building a whole latex document. The first to NULLs in the to_latex structure are for callbacks used for beginning and ending the document. This should be sufficient for the beginning:


\documentclass{article}
\usepackage{hyperref}


\usepackage{graphicx}
\begin{document}


and for the ending:


\end{document}


I contacted the original author about your plugin, and she agrees that it could be included in the official libsoldout repository. You won't have to maintain it, she would do so, but of course you could stay in touch with her if you're interested in the further development.


 


Though you might have spent much effort in this single task, it is a greatly appreciated one.


Regards, Julian 

New version, now with proper escaping and added hooks by fernozzle November 29 2012 05:12 UTC

Hi,


I've submitted a new version with the changes you requested.


Thanks for your help!

Claim Removed by fernozzle November 29 2012 06:45 UTC

The claim on this task has been removed, someone else can claim it now.

Task Claimed by fernozzle November 29 2012 06:45 UTC

I would like to work on this task.

Removing my claim on this task was an accident by fernozzle November 29 2012 06:51 UTC

My removal of my claim on this task was accidental. Sorry about that.

Task Assigned by Aleksej Saushev November 29 2012 09:44 UTC

This task has been assigned to fernozzle. You have 192 hours to complete this task, good luck!

Ready for review by fernozzle November 29 2012 14:43 UTC

The work on this task is ready to be reviewed.

Two minor quirks, but very good nonetheless by gnrp November 30 2012 00:33 UTC

Ok, there are two minor quirks (there's no trailing newline, and escapes are still in the code part, though I think I asked for this). Anyway, you don't have to care for this anymore.


Thank you very much for this great work! We have several other Latex, Markdown and coding related tasks for NetBSD. If you are interested in this, you can look at these, maybe there's another one you want to claim. 

Task Closed by gnrp November 30 2012 00:33 UTC

Congratulations, this task has been completed successfully.

Maybe another task? by gnrp December 3 2012 10:21 UTC

We just created this task: http://www.google-melange.com/gci/task/view/google/gci2012/8015211


Maybe you want to have a look? It's the same as this one. Only this time, you have to write a markdown to terminal converter. This means you have to read a bit into curses and then use the bold, underline, italic characters in curses, and indentation.