forked from kaushalmodi/ox-hugo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ox-hugo-deprecated.el
111 lines (85 loc) · 3.36 KB
/
ox-hugo-deprecated.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
;;; ox-hugo-deprecated.el --- Deprecated stuff from ox-hugo -*- lexical-binding: t -*-
;; Authors: Kaushal Modi <kaushal.modi@gmail.com>
;; URL: https://ox-hugo.scripter.co
;;; Commentary:
;; This file contains variables and functions deprecated from ox-hugo.
;; Do not depend on this file as it may disappear any day.
;;; Obsoletions
;; Blackfriday support is being removed from `ox-hugo' as Hugo has
;; deprecated its support for a while.
;; https://github.com/kaushalmodi/ox-hugo/discussions/485
;;; Code:
(make-obsolete-variable 'org-hugo-blackfriday-options nil "Hugo has switched to use Goldmark as the default Markdown parser since v0.60." "Jan 15, 2022")
(make-obsolete-variable 'org-hugo-blackfriday-extensions nil "Hugo has switched to use Goldmark as the default Markdown parser since v0.60." "Jan 15, 2022")
;;; Variables
(defvar org-hugo-blackfriday-options
'("taskLists"
"smartypants"
"smartypantsQuotesNBSP"
"angledQuotes"
"fractions"
"smartDashes"
"latexDashes"
"hrefTargetBlank"
"plainIDAnchors"
"extensions"
"extensionsmask")
"Deprecated Blackfriday parser option names.")
(defvar org-hugo-blackfriday-extensions
'("noIntraEmphasis"
"tables"
"fencedCode"
"autolink"
"strikethrough"
"laxHtmlBlocks"
"spaceHeaders"
"hardLineBreak"
"tabSizeEight"
"footnotes"
"noEmptyLineBeforeBlock"
"headerIds"
"titleblock"
"autoHeaderIds"
"backslashLineBreak"
"definitionLists"
"joinLines")
"Deprecated Blackfriday extension names.")
;;; Functions
(defun org-hugo--parse-blackfriday-prop-to-alist (str)
"Return an alist of valid Hugo blackfriday properties converted from STR.
For example, input STR:
\":fractions :smartdashes nil :angledquotes t\"
would convert to:
((fractions . \"false\") (smartDashes . \"false\") (angledQuotes . \"true\"))
The \"true\" and \"false\" strings in the return value are due to
`org-hugo--front-matter-value-booleanize'."
(let ((blackfriday-alist (org-hugo--parse-property-arguments str))
valid-blackfriday-alist)
(dolist (ref-prop org-hugo-blackfriday-options)
(dolist (user-prop blackfriday-alist)
(when (string= (downcase (symbol-name (car user-prop)))
(downcase ref-prop))
(let* ((key (intern ref-prop))
(value (cdr user-prop))
(value (if (or (equal key 'extensions)
(equal key 'extensionsmask))
(org-hugo--delim-str-to-list value)
(org-hugo--front-matter-value-booleanize value))))
(push (cons key value)
valid-blackfriday-alist)))))
valid-blackfriday-alist))
(defun org-hugo--return-valid-blackfriday-extension (ext)
"Return valid case-sensitive string for Blackfriday extension EXT.
Example: If EXT is \"hardlinebreak\",
\"\"hardLineBreak\"\" (quoted string) is returned."
(let (ret)
(dolist (ref-ext org-hugo-blackfriday-extensions)
;; (message "ox-hugo bf valid ext DBG: ext=%s ref-ext=%s" ext ref-ext)
(when (string= (downcase ext) (downcase ref-ext))
(setq ret ref-ext)))
(unless ret
(user-error "Invalid Blackfriday extension name %S, see `org-hugo-blackfriday-extensions'"
ext))
(org-hugo--quote-string ret)))
(provide 'ox-hugo-deprecated)
;;; ox-hugo-deprecated.el ends here