Skip to content

naturalcrit/marked-aligned-paragraphs

Repository files navigation

marked-aligned-paragraphs

Add paragraph alignment attributes to paragraphs using HTML base left, right, and center. This syntax borrows the :---: column alignment syntax from Github-flavored Markdown tables.

Left Alignment / Ragged Right

Left-alignment is set by preceeding the paragraph with :--- (any number of hyphens will work)

Example:

:- This is my parapgraph.

Example:

:-----------
This is my
paragraph

Right Alignment / Ragged Left

Right-alignment is set by preceeding the paragraph with ---: (any number of hyphens will work)

Example:

-: This is my parapgraph.

Example:

-----------:
This is my
paragraph

Center Alignment

Center-alignment is set by preceeding the paragraph with :---: (any number of hyphens will work)

Example:

:-: This is my parapgraph.

Example:

:----------:
This is my
paragraph

Notes:

  • Alignment will apply only to the current paragraph (an empty line or end of file)

Usage

const marked = require("marked");
const markedAlignedParagraphs = require("marked-aligned-paragraphs");

marked.use({ extensions: [markedAlignedParagraphs] });

const html = marked.parse(":-: This is a center-aligned paragraph.");
console.log(html);
// <p align="center">This is a center-aligned paragraph.</p>

or

import { Marked } from "marked";
import markedAlignedParagraphs from "marked-aligned-paragraphs";

marked.use({ extensions: [markedAlignedParagraphs] });

const html = marked.parse(":-: This is a center-aligned paragraph.");
console.log(html);
// <p align="center">This is a center-aligned paragraph.</p>

About

Paragraph level justification for Marked.js

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors