Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Body wrapper customization. Fix #280 #281

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,14 @@ provides an interface to all of the possible customizations:
* `markdown-xhtml-header-content` - additional content to include
in the XHTML `<head>` block (default: `""`).

* `markdown-xhtml-body-preamble` - additional content to include in the
XHTML <body> block, before the output. This is useful if you'd like to
wrap the Markdown output around extra elements (default: `""``)."

* `markdown-xhtml-body-epilogue` - additional content to include in the
XHTML <body> block, after the output. This is useful if you'd like to
wrap the Markdown output around extra elements (default: `""``).

* `markdown-xhtml-standalone-regexp` - a regular expression which
`markdown-mode` uses to determine whether the output of
`markdown-command` is a standalone XHTML document or an XHTML
Expand Down
27 changes: 27 additions & 0 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
;; Maintainer: Jason R. Blevins <jblevins@xbeta.org>
;; Created: May 24, 2007
;; Version: 2.4-dev
;; Package-Version: 20171031.1725
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this Package-Version header.

;; Package-Requires: ((emacs "24") (cl-lib "0.5"))
;; Keywords: Markdown, GitHub Flavored Markdown, itex
;; URL: https://jblevins.org/projects/markdown-mode/
Expand Down Expand Up @@ -758,6 +759,14 @@
;; * `markdown-xhtml-header-content' - additional content to include
;; in the XHTML `<head>` block (default: `""`).
;;
;; * `markdown-xhtml-body-preamble' - additional content to include in the
;; XHTML <body> block, before the output. This is useful if you'd like to
;; wrap the Markdown output around extra elements (default: `""`')."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray single quote (`) here.

;;
;; * `markdown-xhtml-body-epilogue' - additional content to include in the
;; XHTML <body> block, after the output. This is useful if you'd like to
;; wrap the Markdown output around extra elements (default: `""`').
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray single quote (`) here also.

;;
;; * `markdown-xhtml-standalone-regexp' - a regular expression which
;; `markdown-mode' uses to determine whether the output of
;; `markdown-command' is a standalone XHTML document or an XHTML
Expand Down Expand Up @@ -1360,6 +1369,18 @@ and `iso-latin-1'. Use `list-coding-systems' for more choices."
:group 'markdown
:type 'string)

(defcustom markdown-xhtml-body-preamble ""
"Additional content to include in the XHTML <body> block, before the output.
This is useful if you'd like to wrap the Markdown output around extra elements."
:group 'markdown
:type 'string)

(defcustom markdown-xhtml-body-epilogue ""
"Additional content to include in the XHTML <body> block, after the output.
This is useful if you'd like to wrap the Markdown output around extra elements."
:group 'markdown
:type 'string)

(defcustom markdown-xhtml-standalone-regexp
"^\\(<\\?xml\\|<!DOCTYPE\\|<html\\)"
"Regexp indicating whether `markdown-command' output is standalone XHTML."
Expand Down Expand Up @@ -7770,7 +7791,13 @@ Standalone XHTML output is identified by an occurrence of
(insert markdown-xhtml-header-content))
(insert "\n</head>\n\n"
"<body>\n\n")
(when (> (length markdown-xhtml-body-preamble) 0)
(insert markdown-xhtml-body-preamble))
(insert "\n")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to put this newline inside the when block, so that existing output for those who haven't customized this variable will be exactly the same.

(goto-char (point-max))
(insert "\n")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this newline (see above).

(when (> (length markdown-xhtml-body-epilogue) 0)
(insert markdown-xhtml-body-epilogue))
(insert "\n"
"</body>\n"
"</html>\n"))
Expand Down