kramdown 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTERS +15 -14
- data/README.md +18 -16
- data/VERSION +1 -1
- data/lib/kramdown/converter/base.rb +1 -1
- data/lib/kramdown/converter/hash_ast.rb +1 -1
- data/lib/kramdown/converter/html.rb +10 -3
- data/lib/kramdown/converter/kramdown.rb +1 -1
- data/lib/kramdown/converter/latex.rb +1 -1
- data/lib/kramdown/converter/man.rb +1 -1
- data/lib/kramdown/converter/math_engine/mathjax.rb +1 -1
- data/lib/kramdown/converter/remove_html_tags.rb +1 -1
- data/lib/kramdown/converter/syntax_highlighter/minted.rb +1 -1
- data/lib/kramdown/converter/syntax_highlighter/rouge.rb +32 -3
- data/lib/kramdown/converter/syntax_highlighter.rb +1 -1
- data/lib/kramdown/converter/toc.rb +1 -1
- data/lib/kramdown/converter.rb +1 -1
- data/lib/kramdown/document.rb +1 -1
- data/lib/kramdown/element.rb +1 -1
- data/lib/kramdown/error.rb +1 -1
- data/lib/kramdown/options.rb +22 -3
- data/lib/kramdown/parser/base.rb +2 -2
- data/lib/kramdown/parser/html.rb +13 -6
- data/lib/kramdown/parser/kramdown/abbreviation.rb +2 -2
- data/lib/kramdown/parser/kramdown/autolink.rb +1 -1
- data/lib/kramdown/parser/kramdown/blank_line.rb +1 -1
- data/lib/kramdown/parser/kramdown/block_boundary.rb +2 -2
- data/lib/kramdown/parser/kramdown/blockquote.rb +1 -1
- data/lib/kramdown/parser/kramdown/codeblock.rb +2 -2
- data/lib/kramdown/parser/kramdown/codespan.rb +1 -1
- data/lib/kramdown/parser/kramdown/emphasis.rb +4 -3
- data/lib/kramdown/parser/kramdown/eob.rb +1 -1
- data/lib/kramdown/parser/kramdown/escaped_chars.rb +1 -1
- data/lib/kramdown/parser/kramdown/extensions.rb +9 -7
- data/lib/kramdown/parser/kramdown/footnote.rb +1 -1
- data/lib/kramdown/parser/kramdown/header.rb +1 -1
- data/lib/kramdown/parser/kramdown/horizontal_rule.rb +1 -1
- data/lib/kramdown/parser/kramdown/html.rb +8 -6
- data/lib/kramdown/parser/kramdown/html_entity.rb +1 -1
- data/lib/kramdown/parser/kramdown/line_break.rb +1 -1
- data/lib/kramdown/parser/kramdown/link.rb +37 -5
- data/lib/kramdown/parser/kramdown/list.rb +6 -4
- data/lib/kramdown/parser/kramdown/math.rb +1 -1
- data/lib/kramdown/parser/kramdown/paragraph.rb +1 -1
- data/lib/kramdown/parser/kramdown/smart_quotes.rb +1 -1
- data/lib/kramdown/parser/kramdown/table.rb +2 -2
- data/lib/kramdown/parser/kramdown/typographic_symbol.rb +1 -1
- data/lib/kramdown/parser/kramdown.rb +11 -4
- data/lib/kramdown/parser/markdown.rb +1 -1
- data/lib/kramdown/parser.rb +1 -1
- data/lib/kramdown/utils/configurable.rb +1 -1
- data/lib/kramdown/utils/entities.rb +1 -1
- data/lib/kramdown/utils/html.rb +1 -1
- data/lib/kramdown/utils/lru_cache.rb +1 -1
- data/lib/kramdown/utils/string_scanner.rb +8 -9
- data/lib/kramdown/utils/unidecoder.rb +1 -1
- data/lib/kramdown/utils.rb +1 -1
- data/lib/kramdown/version.rb +2 -2
- data/lib/kramdown.rb +1 -1
- data/man/man1/kramdown.1 +6 -2
- data/test/run_tests.rb +1 -1
- data/test/test_files.rb +8 -2
- data/test/test_location.rb +1 -1
- data/test/test_string_scanner_kramdown.rb +1 -1
- data/test/testcases/block/04_header/with_custom_header_links.html +1 -0
- data/test/testcases/block/04_header/with_custom_header_links.options +4 -0
- data/test/testcases/block/04_header/with_custom_header_links.text +1 -0
- data/test/testcases/span/01_link/imagelinks.html +4 -0
- data/test/testcases/span/01_link/imagelinks.text +7 -0
- data/test/testcases/span/01_link/unclosed_brackets.html +5 -0
- data/test/testcases/span/01_link/unclosed_brackets.text +5 -0
- data/test/testcases/span/04_footnote/empty_definition.html +12 -0
- data/test/testcases/span/04_footnote/empty_definition.text +3 -0
- metadata +14 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 37113348d6ccaaec5d96f26a69f1c3a27f7766e332373d1fd1e71fb21e9547b7
|
|
4
|
+
data.tar.gz: ae0bfa570fc4bafca6f5d88e2008e051857672dae7bd025db61919a124ee06c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e71bb106b34d3d8dda194c9d1ab3aeb8e1db3ab7da6cc1306087f14184fd2ed65bec9cb01a783df1cd20097f5a08d0bdea1fc2b7e482203c091f2d6901ea617e
|
|
7
|
+
data.tar.gz: 21e40759e423b619cf4241dabfbbaa89736bb59891f21af807257ff5e93764749e1ec69401504243d11df7fc5a2e22e4c276abf438a01fb420813b02fa65dea9
|
data/CONTRIBUTERS
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Count Name
|
|
2
2
|
======= ====
|
|
3
|
-
|
|
3
|
+
1008 Thomas Leitner <t_leitner@gmx.at>
|
|
4
4
|
18 Ashwin Maroli <ashmaroli@gmail.com>
|
|
5
5
|
7 Christian Cornelssen <ccorn@1tein.de>
|
|
6
6
|
6 Gioele Barabucci <gioele@svario.it>
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
4 Shuanglei Tao <tsl0922@gmail.com>
|
|
10
10
|
4 Dan Allen <dan.j.allen@gmail.com>
|
|
11
11
|
4 Arne Brasseur <arne@arnebrasseur.net>
|
|
12
|
-
3 Henning Perl <perl@fast-sicher.de>
|
|
13
12
|
3 gettalong <t_leitner@gmx.at>
|
|
13
|
+
3 Henning Perl <perl@fast-sicher.de>
|
|
14
14
|
3 Carsten Bormann <cabo@tzi.org>
|
|
15
15
|
3 Brandur <brandur@mutelight.org>
|
|
16
16
|
3 Ben Armston <ben.armston@googlemail.com>
|
|
@@ -23,35 +23,38 @@
|
|
|
23
23
|
2 Jo Hund <jhund@clearcove.ca>
|
|
24
24
|
2 Bryce Willey <Bryce.Steven.Willey@gmail.com>
|
|
25
25
|
2 Bran <m.versum@gmail.com>
|
|
26
|
+
1 youdie006 <xncb135@korea.ac.kr>
|
|
26
27
|
1 winniehell <git@winniehell.de>
|
|
28
|
+
1 utenmiki <utenmiki@gmail.com>
|
|
29
|
+
1 tomykaira <tomykaira@gmail.com>
|
|
30
|
+
1 tom93 <tomlevy93@gmail.com>
|
|
31
|
+
1 timcraft <mail@timcraft.com>
|
|
32
|
+
1 scherr <maximilianscherr@gmail.com>
|
|
33
|
+
1 myqlarson <myqlarson@gmail.com>
|
|
34
|
+
1 milo.simpson <milo.simpson@bazaarvoice.com>
|
|
35
|
+
1 l3kn <hello@l3kn.de>
|
|
36
|
+
1 aschmitz <29508+aschmitz@users.noreply.github.com>
|
|
27
37
|
1 William <suttonwilliamd@gmail.com>
|
|
28
38
|
1 Virgil Ierubino <30758921+Convincible@users.noreply.github.com>
|
|
29
39
|
1 Uwe Kubosch <donv@users.noreply.github.com>
|
|
30
|
-
1 utenmiki <utenmiki@gmail.com>
|
|
31
40
|
1 Trevor Wennblom <trevor@well.com>
|
|
32
|
-
1 tomykaira <tomykaira@gmail.com>
|
|
33
|
-
1 tom93 <tomlevy93@gmail.com>
|
|
34
41
|
1 Tobin Yehle <tobinyehle@gmail.com>
|
|
35
|
-
1 timcraft <mail@timcraft.com>
|
|
36
42
|
1 Tim Blair <tim@bla.ir>
|
|
37
43
|
1 Tim Besard <tim.besard@gmail.com>
|
|
38
44
|
1 Tim Bates <tim@rumpuslabs.com>
|
|
39
45
|
1 Sun Yaozhu <yzyzsun@gmail.com>
|
|
40
|
-
1 Stephen <stephengroat@users.noreply.github.com>
|
|
41
46
|
1 Stephen Crosby <stevecrozz@gmail.com>
|
|
47
|
+
1 Stephen <stephengroat@users.noreply.github.com>
|
|
42
48
|
1 Stan Hu <stanhu@gmail.com>
|
|
43
49
|
1 Simon Lydell <simon.lydell@gmail.com>
|
|
44
50
|
1 Simon Coffey <simon.coffey@futurelearn.com>
|
|
45
51
|
1 Shusaku NAKAZATO <cu393uc@gmail.com>
|
|
46
52
|
1 Sebastian Boehm <sebastian@sometimesfood.org>
|
|
47
|
-
1 scherr <maximilianscherr@gmail.com>
|
|
48
53
|
1 Postmodern <postmodern.mod3@gmail.com>
|
|
49
54
|
1 Pete Michaud <michaudp@gmail.com>
|
|
50
55
|
1 Paul McMahon <paul@tokyodev.com>
|
|
51
56
|
1 Paul <2528280+psfrolov@users.noreply.github.com>
|
|
52
57
|
1 Noah Doersing <doersino@gmail.com>
|
|
53
|
-
1 myqlarson <myqlarson@gmail.com>
|
|
54
|
-
1 milo.simpson <milo.simpson@bazaarvoice.com>
|
|
55
58
|
1 Michal Till <michal.till@gmail.com>
|
|
56
59
|
1 Maxime Kjaer <maxime.kjaer@gmail.com>
|
|
57
60
|
1 Matt Hickford <matt.hickford@gmail.com>
|
|
@@ -59,7 +62,6 @@
|
|
|
59
62
|
1 Marek Tuchowski <marek@tuchowski.com.pl>
|
|
60
63
|
1 Marcus Stollsteimer <sto.mar@web.de>
|
|
61
64
|
1 Luca Barbato <luca.barbato@gmail.com>
|
|
62
|
-
1 l3kn <hello@l3kn.de>
|
|
63
65
|
1 Kir Kolyshkin <kolyshkin@gmail.com>
|
|
64
66
|
1 Jun Aruga <jaruga@redhat.com>
|
|
65
67
|
1 Jonathan Hooper <jonathan.hooper@gsa.gov>
|
|
@@ -77,17 +79,16 @@
|
|
|
77
79
|
1 David Rodríguez <deivid.rodriguez@riseup.net>
|
|
78
80
|
1 Daniel Bair <daniel@danielbair.com>
|
|
79
81
|
1 Damien Pollet <damien.pollet@gmail.com>
|
|
82
|
+
1 Cédric Boutillier <cedric.boutillier@gmail.com>
|
|
80
83
|
1 Christopher Jefferson <caj21@st-andrews.ac.uk>
|
|
81
84
|
1 Christian Boos <christian.boos@bct-technology.com>
|
|
82
|
-
1 Cédric Boutillier <cedric.boutillier@gmail.com>
|
|
83
85
|
1 Bob Lail <lail@squareup.com>
|
|
84
86
|
1 Ashesh Kumar Singh <user501254@gmail.com>
|
|
85
87
|
1 Ashe Connor <ashe@kivikakk.ee>
|
|
86
|
-
1 aschmitz <29508+aschmitz@users.noreply.github.com>
|
|
87
88
|
1 Antoine Cotten <hello@acotten.com>
|
|
88
89
|
1 Andrew <andrew.dale.wylie@gmail.com>
|
|
89
90
|
1 Alpha Chen <alpha.chen@gmail.com>
|
|
91
|
+
1 Alexey Vasiliev <le0pard@users.noreply.github.com>
|
|
90
92
|
1 Alex Tomlins <alex.tomlins@digital.cabinet-office.gov.uk>
|
|
91
93
|
1 Alex Taylor <alex@alextaylor.ca>
|
|
92
|
-
1 Alexey Vasiliev <le0pard@users.noreply.github.com>
|
|
93
94
|
1 284km <k.furuhashi10@gmail.com>
|
data/README.md
CHANGED
|
@@ -2,18 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Readme first!
|
|
4
4
|
|
|
5
|
-
kramdown was originally licensed under the GPL until the 1.0.0 release. However, due to the many
|
|
6
|
-
requests it is now released under the MIT license and therefore can easily be used in commercial
|
|
7
|
-
projects, too.
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
changes** for the benefit of the community and/or [**becoming a
|
|
11
|
-
sponsor**](https://github.com/sponsors/gettalong/) or [**a
|
|
12
|
-
patron**](https://www.patreon.com/gettalong) - thanks!
|
|
6
|
+
## Sponsors
|
|
13
7
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* **GROSSWEBER** provides <a href="http://grossweber.com/b/kramdown" target="_blank">software
|
|
8
|
+
* **GROSSWEBER** provides <a href="https://grossweber.com/b/kramdown" target="_blank">software
|
|
17
9
|
development consulting and training services</a>.
|
|
18
10
|
|
|
19
11
|
|
|
@@ -23,8 +15,8 @@ kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax
|
|
|
23
15
|
supporting several common extensions.
|
|
24
16
|
|
|
25
17
|
The syntax definition for the kramdown syntax can be found in **doc/syntax.page** (or online at
|
|
26
|
-
<
|
|
27
|
-
**doc/quickref.page** or online at <
|
|
18
|
+
<https://kramdown.gettalong.org/syntax.html>) and a quick reference is available in
|
|
19
|
+
**doc/quickref.page** or online at <https://kramdown.gettalong.org/quickref.html>.
|
|
28
20
|
|
|
29
21
|
The kramdown library is mainly written to support the kramdown-to-HTML conversion chain. However,
|
|
30
22
|
due to its flexibility (by creating an internal AST) it supports other input and output formats as
|
|
@@ -34,14 +26,14 @@ well. Here is a list of the supported formats:
|
|
|
34
26
|
* output formats: HTML, kramdown, LaTeX (and therefore PDF), PDF via Prawn
|
|
35
27
|
|
|
36
28
|
All the documentation on the available input and output formats is available in the **doc/**
|
|
37
|
-
directory and online at <
|
|
29
|
+
directory and online at <https://kramdown.gettalong.org>.
|
|
38
30
|
|
|
39
31
|
Starting from version 1.0.0 kramdown is using a versioning scheme with major, minor and patch parts
|
|
40
32
|
in the version number where the major number changes on backwards-incompatible changes, the minor
|
|
41
33
|
number on the introduction of new features and the patch number on everything else.
|
|
42
34
|
|
|
43
35
|
For information about changes between versions, have a look at
|
|
44
|
-
<
|
|
36
|
+
<https://kramdown.gettalong.org/news.html> or the commit history!
|
|
45
37
|
|
|
46
38
|
|
|
47
39
|
## Usage
|
|
@@ -56,8 +48,8 @@ Kramdown::Document.new(text).to_html
|
|
|
56
48
|
|
|
57
49
|
For detailed information have a look at the API documentation of the `Kramdown::Document` class.
|
|
58
50
|
|
|
59
|
-
The full API documentation is available at <
|
|
60
|
-
API documentation for kramdown probably don't provide the complete documentation!
|
|
51
|
+
The full API documentation is available at <https://kramdown.gettalong.org/rdoc/>, other sites with
|
|
52
|
+
an API documentation for kramdown probably don't provide the complete documentation!
|
|
61
53
|
|
|
62
54
|
There are also some third-party libraries that extend the functionality of kramdown -- see the
|
|
63
55
|
kramdown Wiki at <https://github.com/gettalong/kramdown/wiki>.
|
|
@@ -75,3 +67,13 @@ programs like `tidy` and `latex`. See the `.travis.yml` file for more informatio
|
|
|
75
67
|
## License
|
|
76
68
|
|
|
77
69
|
MIT - see the **COPYING** file.
|
|
70
|
+
|
|
71
|
+
kramdown was originally licensed under the GPL until the 1.0.0 release. However, due to the many
|
|
72
|
+
requests it is now released under the MIT license and therefore can easily be used in commercial
|
|
73
|
+
projects, too.
|
|
74
|
+
|
|
75
|
+
However, if you use kramdown in a commercial setting, please consider **contributing back any
|
|
76
|
+
changes** for the benefit of the community and/or [**becoming a
|
|
77
|
+
sponsor**](https://github.com/sponsors/gettalong/) or [**a
|
|
78
|
+
patron**](https://www.patreon.com/gettalong) - thanks!
|
|
79
|
+
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.6.0
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
|
-
# Copyright (C) 2009-
|
|
4
|
+
# Copyright (C) 2009-2026 Thomas Leitner <t_leitner@gmx.at>
|
|
5
5
|
#
|
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
|
7
7
|
#++
|
|
@@ -155,7 +155,14 @@ module Kramdown
|
|
|
155
155
|
if @options[:header_links] && attr['id'].to_s.length > 0
|
|
156
156
|
link = Element.new(:a, nil, nil)
|
|
157
157
|
link.attr['href'] = "##{attr['id']}"
|
|
158
|
-
|
|
158
|
+
unless (header_link_text = @options[:header_links][:content].to_s).empty?
|
|
159
|
+
link.children << Element.new(:text, header_link_text)
|
|
160
|
+
end
|
|
161
|
+
if @options[:header_links][:position].to_s == 'start'
|
|
162
|
+
el.children.unshift(link)
|
|
163
|
+
else
|
|
164
|
+
el.children.push(link)
|
|
165
|
+
end
|
|
159
166
|
end
|
|
160
167
|
|
|
161
168
|
@toc << [el.options[:level], attr['id'], el.children] if attr['id'] && in_toc?(el)
|
|
@@ -504,7 +511,7 @@ module Kramdown
|
|
|
504
511
|
li.children = Marshal.load(Marshal.dump(data.children))
|
|
505
512
|
|
|
506
513
|
para = nil
|
|
507
|
-
if li.children.last
|
|
514
|
+
if li.children.last&.type == :p || @options[:footnote_backlink_inline]
|
|
508
515
|
parent = li
|
|
509
516
|
while !parent.children.empty? && ![:p, :header].include?(parent.children.last.type)
|
|
510
517
|
parent = parent.children.last
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
|
-
# Copyright (C) 2009-
|
|
4
|
+
# Copyright (C) 2009-2026 Thomas Leitner <t_leitner@gmx.at>
|
|
5
5
|
#
|
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
|
7
7
|
#++
|
|
@@ -17,6 +17,36 @@ module Kramdown::Converter::SyntaxHighlighter
|
|
|
17
17
|
|
|
18
18
|
# Highlighting via Rouge is available if this constant is +true+.
|
|
19
19
|
AVAILABLE = true
|
|
20
|
+
|
|
21
|
+
# This is the HTMLLegacy implementation from Rouge that is deprecated. Therefore it is
|
|
22
|
+
# reproduced here and only adapted as needed.
|
|
23
|
+
class HTMLLegacy < ::Rouge::Formatter
|
|
24
|
+
def initialize(opts = {})
|
|
25
|
+
@formatter = if opts[:inline_theme]
|
|
26
|
+
::Rouge::Formatters::HTMLInline.new(opts[:inline_theme])
|
|
27
|
+
else
|
|
28
|
+
::Rouge::Formatters::HTML.new
|
|
29
|
+
end
|
|
30
|
+
@formatter = ::Rouge::Formatters::HTMLTable.new(@formatter, opts) if opts[:line_numbers]
|
|
31
|
+
|
|
32
|
+
if opts.fetch(:wrap, true)
|
|
33
|
+
@pygments_wrap = opts.fetch(:css_class, 'codehilite')
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def stream(tokens, &b)
|
|
38
|
+
if @pygments_wrap
|
|
39
|
+
yield %(<div class="highlight"><pre class="#{@pygments_wrap}"><code>)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
@formatter.stream(tokens, &b)
|
|
43
|
+
|
|
44
|
+
if @pygments_wrap
|
|
45
|
+
yield "</code></pre></div>"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
20
50
|
rescue LoadError, SyntaxError
|
|
21
51
|
AVAILABLE = false # :nodoc:
|
|
22
52
|
end
|
|
@@ -72,8 +102,7 @@ module Kramdown::Converter::SyntaxHighlighter
|
|
|
72
102
|
when /\A[[:upper:]][[:alnum:]_]*\z/
|
|
73
103
|
::Rouge::Formatters.const_get(formatter, false)
|
|
74
104
|
else
|
|
75
|
-
|
|
76
|
-
::Rouge::Formatters::HTMLLegacy
|
|
105
|
+
HTMLLegacy
|
|
77
106
|
end
|
|
78
107
|
rescue NameError
|
|
79
108
|
# Fallback to Rouge 1.x
|
data/lib/kramdown/converter.rb
CHANGED
data/lib/kramdown/document.rb
CHANGED
data/lib/kramdown/element.rb
CHANGED
data/lib/kramdown/error.rb
CHANGED
data/lib/kramdown/options.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
|
-
# Copyright (C) 2009-
|
|
4
|
+
# Copyright (C) 2009-2026 Thomas Leitner <t_leitner@gmx.at>
|
|
5
5
|
#
|
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
|
7
7
|
#++
|
|
@@ -236,14 +236,33 @@ module Kramdown
|
|
|
236
236
|
Used by: HTML/Latex converter
|
|
237
237
|
EOF
|
|
238
238
|
|
|
239
|
-
define(:header_links,
|
|
239
|
+
define(:header_links, Object, false, <<~EOF) do |val|
|
|
240
240
|
Adds anchor tags within headers that can be used to generate permalinks
|
|
241
241
|
when not using a table of contents.
|
|
242
242
|
|
|
243
|
-
|
|
243
|
+
If the value is `false`, no header links are used; if `true`, the defaults
|
|
244
|
+
are used: The anchor tags are empty and at the start of the header element.
|
|
245
|
+
This can be changed by using a hash as value with the following symbol keys:
|
|
246
|
+
|
|
247
|
+
* content: Defines the content of the anchor tag, default is ''.
|
|
248
|
+
* position: Whether the anchor tag is placed at the 'start' or the 'end' of
|
|
249
|
+
the header tag, default is 'start'.
|
|
244
250
|
|
|
245
251
|
Default: false
|
|
246
252
|
EOF
|
|
253
|
+
case val
|
|
254
|
+
when FalseClass
|
|
255
|
+
val
|
|
256
|
+
when TrueClass
|
|
257
|
+
{content: '', position: :start}
|
|
258
|
+
else
|
|
259
|
+
val = simple_hash_validator(val, :header_links)
|
|
260
|
+
val.keys.each do |k|
|
|
261
|
+
val[k.kind_of?(String) ? str_to_sym(k) : k] = val.delete(k)
|
|
262
|
+
end
|
|
263
|
+
val
|
|
264
|
+
end
|
|
265
|
+
end
|
|
247
266
|
|
|
248
267
|
define(:transliterated_header_ids, Boolean, false, <<~EOF)
|
|
249
268
|
Transliterate the header text before generating the ID
|
data/lib/kramdown/parser/base.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
|
-
# Copyright (C) 2009-
|
|
4
|
+
# Copyright (C) 2009-2026 Thomas Leitner <t_leitner@gmx.at>
|
|
5
5
|
#
|
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
|
7
7
|
#++
|
|
@@ -57,7 +57,7 @@ module Kramdown
|
|
|
57
57
|
|
|
58
58
|
@root.options[:abbrev_defs].default_proc = @root.options[:abbrev_attr].default_proc =
|
|
59
59
|
lambda do |h, k|
|
|
60
|
-
k_mod = k.gsub(/[\
|
|
60
|
+
k_mod = k.gsub(/[\p{Z}\t\r\n\f\v]+/m, " ")
|
|
61
61
|
k != k_mod ? h[k_mod] : nil
|
|
62
62
|
end
|
|
63
63
|
@warnings = []
|
data/lib/kramdown/parser/html.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
|
-
# Copyright (C) 2009-
|
|
4
|
+
# Copyright (C) 2009-2026 Thomas Leitner <t_leitner@gmx.at>
|
|
5
5
|
#
|
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
|
7
7
|
#++
|
|
@@ -73,8 +73,8 @@ module Kramdown
|
|
|
73
73
|
|
|
74
74
|
# Contains the parsing methods. This module can be mixed into any parser to get HTML parsing
|
|
75
75
|
# functionality. The only thing that must be provided by the class are instance variable
|
|
76
|
-
# @stack for storing the needed state
|
|
77
|
-
# parsing.
|
|
76
|
+
# @stack for storing the needed state, @src (instance of StringScanner) for the actual
|
|
77
|
+
# parsing and @stack_counter for checking nested element level.
|
|
78
78
|
module Parser
|
|
79
79
|
|
|
80
80
|
include Constants
|
|
@@ -149,6 +149,8 @@ module Kramdown
|
|
|
149
149
|
# When an HTML start tag is found, processing is deferred to #handle_html_start_tag,
|
|
150
150
|
# providing the block given to this method.
|
|
151
151
|
def parse_raw_html(el, &block)
|
|
152
|
+
@stack_counter += 1
|
|
153
|
+
raise Kramdown::Error, "Elements nested too deep at HTML raw level" if @stack_counter > 200
|
|
152
154
|
@stack.push(@tree)
|
|
153
155
|
@tree = el
|
|
154
156
|
|
|
@@ -157,11 +159,14 @@ module Kramdown
|
|
|
157
159
|
if (result = @src.scan_until(HTML_RAW_START))
|
|
158
160
|
add_text(result, @tree, :text)
|
|
159
161
|
line = @src.current_line_number
|
|
160
|
-
if (
|
|
162
|
+
if @src.skip(/<!--/) && (r = @src.exist?(/-->/); @src.pos -= 4; r)
|
|
163
|
+
result = @src.scan(HTML_COMMENT_RE)
|
|
161
164
|
@tree.children << Element.new(:xml_comment, result, nil, category: :block, location: line)
|
|
162
|
-
elsif (
|
|
165
|
+
elsif @src.skip(/<\?/) && (r = @src.exist?(/\?>/); @src.pos -= 2; r)
|
|
166
|
+
result = @src.scan(HTML_INSTRUCTION_RE)
|
|
163
167
|
@tree.children << Element.new(:xml_pi, result, nil, category: :block, location: line)
|
|
164
|
-
elsif @src.
|
|
168
|
+
elsif @src.skip(/<!\[CDATA\[/) && (r = @src.exist?(/\]\]>/); @src.pos -= 9; r)
|
|
169
|
+
@src.scan(HTML_CDATA_RE)
|
|
165
170
|
@tree.children << Element.new(:text, @src[1], nil, cdata: true, location: line)
|
|
166
171
|
elsif @src.scan(HTML_TAG_RE)
|
|
167
172
|
if method(:handle_html_start_tag).arity.abs >= 1
|
|
@@ -191,6 +196,7 @@ module Kramdown
|
|
|
191
196
|
end
|
|
192
197
|
end
|
|
193
198
|
|
|
199
|
+
@stack_counter -= 1
|
|
194
200
|
@tree = @stack.pop
|
|
195
201
|
end
|
|
196
202
|
|
|
@@ -591,6 +597,7 @@ module Kramdown
|
|
|
591
597
|
|
|
592
598
|
# Parse the source string provided on initialization as HTML document.
|
|
593
599
|
def parse
|
|
600
|
+
@stack_counter = 0
|
|
594
601
|
@stack, @tree = [], @root
|
|
595
602
|
@src = Kramdown::Utils::StringScanner.new(adapt_source(source))
|
|
596
603
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
|
-
# Copyright (C) 2009-
|
|
4
|
+
# Copyright (C) 2009-2026 Thomas Leitner <t_leitner@gmx.at>
|
|
5
5
|
#
|
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
|
7
7
|
#++
|
|
@@ -43,7 +43,7 @@ module Kramdown
|
|
|
43
43
|
unless regexps
|
|
44
44
|
sorted_abbrevs = @root.options[:abbrev_defs].keys.sort {|a, b| b.length <=> a.length }
|
|
45
45
|
regexps = [Regexp.union(*sorted_abbrevs.map do |k|
|
|
46
|
-
/#{Regexp.escape(k).gsub(/\\\s/, "[\\
|
|
46
|
+
/#{Regexp.escape(k).gsub(/\\\s/, "[\\t\\r\\n\\f\\v\\p{Z}]+").force_encoding(Encoding::UTF_8)}/
|
|
47
47
|
end)]
|
|
48
48
|
regexps << /(?=(?:\W|^)#{regexps.first}(?!\w))/ # regexp should only match on word boundaries
|
|
49
49
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
|
-
# Copyright (C) 2009-
|
|
4
|
+
# Copyright (C) 2009-2026 Thomas Leitner <t_leitner@gmx.at>
|
|
5
5
|
#
|
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
|
7
7
|
#++
|
|
@@ -26,7 +26,7 @@ module Kramdown
|
|
|
26
26
|
|
|
27
27
|
# Return +true+ if we are before a block boundary.
|
|
28
28
|
def before_block_boundary?
|
|
29
|
-
@src.
|
|
29
|
+
@src.match?(self.class::BLOCK_BOUNDARY)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8; frozen_string_literal: true -*-
|
|
2
2
|
#
|
|
3
3
|
#--
|
|
4
|
-
# Copyright (C) 2009-
|
|
4
|
+
# Copyright (C) 2009-2026 Thomas Leitner <t_leitner@gmx.at>
|
|
5
5
|
#
|
|
6
6
|
# This file is part of kramdown which is licensed under the MIT.
|
|
7
7
|
#++
|
|
@@ -35,7 +35,7 @@ module Kramdown
|
|
|
35
35
|
|
|
36
36
|
# Parse the fenced codeblock at the current location.
|
|
37
37
|
def parse_codeblock_fenced
|
|
38
|
-
if @src.
|
|
38
|
+
if @src.match?(self.class::FENCED_CODEBLOCK_MATCH)
|
|
39
39
|
start_line_number = @src.current_line_number
|
|
40
40
|
@src.pos += @src.matched_size
|
|
41
41
|
el = new_block_el(:codeblock, @src[5], nil, location: start_line_number, fenced: true)
|