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 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 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 is set by preceeding the paragraph with :---: (any number of hyphens will work)
Example:
:-: This is my parapgraph.
Example:
:----------:
This is my
paragraph
- Alignment will apply only to the current paragraph (an empty line or end of file)
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>