npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@adrianjost/md2tex

v1.3.0

Published

bachelor thesis basic Markdown to Latex converter

Downloads

129

Readme

An opinionated Markdown to Latex Converter

Build Status codecov

npm (scoped) npm npm bundle size (scoped)

Warning: This Code is a total mess! I am sorry for that. But it has 100% test coverage so whenever someone introduces a new hack to get it working, we can be confident that nothing unexpectedly breaks.

All features were developed for compatibility with the modernthesis template.

How to use it

As a standalone converter

Install

# yarn
yarn global add @adrianjost/md2tex

# or npm
npm i -g @adrianjost/md2tex

Usage

md2tex "pathToSrcMdFile" "pathToTargetTexFile"
  • The pathToSrcMdFile default to ./in.md.
  • The pathToTargetTexFile default to ./out.tex.

If you provide a directory path instead of a file for both paths, all .md files will get converted to the output directory. The Filestructure will remain the same.

As a regular dependency

Install

# yarn
yarn add -D @adrianjost/md2tex

# or npm
npm i -D @adrianjost/md2tex

Usage

import md2tex from "@adrianjost/md2tex";
// or
// const { convert: md2tex } = require("@adrianjost/md2tex")

const md = `# Hello World`;
const tex = md2tex(md);
console.log(tex);

Features

You can use a codeblock with the language latex to write latex code directly in your markdown files. This Code is getting directly copied into the output without any further conversion.

Headlines

Input:

# H1
## H2
### H3
#### H4
##### H5
###### H6

Output:

%************************************************
\chapter{H1}
\label{ch:0-h1}
%************************************************
\hypertarget{1-h2}{
\section{H2}\label{1-h2}}
\hypertarget{2-h3}{
\subsection{H3}\label{2-h3}}
\hypertarget{3-h4}{
\subsubsection{H4}\label{3-h4}}
\hypertarget{4-h5}{
\paragraph{H5}\label{4-h5}}
\hypertarget{5-h6}{
\subparagraph{H6}\label{5-h6}}

Text Styles

Input:

**bold** or **bold**
_italic_ or _italic_
`inline code`

Output:

\textbf{bold} or \textbf{bold} \\
\textit{italic} or \textit{italic} \\
\colorbox{gray-light!}{\texttt{inline code}}

Links

Links get converted to footnotes or BibLatex Source References

Input:

[descrition](footnote)

[source](`reference`)

Output:

description\\footnote{footnote}

description\\cite{reference}

Images

Input:

![description](path)

Output:

\begin{figure}[H]
	\centering
	\includegraphics[width=\textwidth]{path}
	\caption[description]{description}
	\label{fig:description}
\end{figure}

Codeblocks

🌟 Please note the special syntax for captions.

Input:

```js [some caption]
console.log("Hi");
```[description]

Output:

\begin{listing}[H]
	\begin{minted}{js}
console.log("Hi");
	\end{minted}
	\caption{some caption}
	\label{lst:code-snipped-undefined}
\end{listing}

Lists

Input:

- list item 1
	- indentation 1
- list item 2

1. first
2. second

Output:

\begin{itemize}
	\item list item 1
	\begin{itemize}
		\item indentation 1
	\end{itemize}
	\item list item 2
\end{itemize}

\begin{enumerate}
	\item first

	\item second
\end{enumerate}

Known Limitations

  • Currently, this code can't convert tables
  • It is also not possible to use inline styles in headlines like # _italic_ headline
  • Not all characters get escaped correctly. It's not working inside headlines and normal text without any formatting.

Contribute

You wan't to contribute? Feel free to do so!

If you have found a bug, just add a snapshot test to the tests located at __tests__/md2tex.test.js and open a pull request.