gitlab-glfm-markdown 0.0.42 → 0.0.43

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '05901fb48fae32f9bb573996251dd8d1af629dbea739b2fb8d3d01541b8fd13b'
4
- data.tar.gz: 895c392cf75e43a585c80ca7611a1d7a8e4e1d9c248a5c249a5819d57e863e2c
3
+ metadata.gz: f236556687b3d729bf99f61ba5a52a27354e064584417318ab4d259d9646ba35
4
+ data.tar.gz: a66700301509b9ba291aca76d726f7129c32226350f2d281232d32d0b2c51ece
5
5
  SHA512:
6
- metadata.gz: c13f49a35e8c78390bc8e77f5639b00c7f0f4347ca4a08af655384ebc562f3fdf1f32ea1b730b8f5498a5b3635bd186c4a2fe3893aaa17c3571df425d70a3409
7
- data.tar.gz: 299b6575bfce5b79c475c3bb59fa36740b4d670eedd0b9de103cc5f8f1a1fbe3c8138db3d603239cc959f9e3bae39c4eeebc807baeb71298de7cdfc4a7262b41
6
+ metadata.gz: 9da0edd36ed0c3b9f503ccbbfa7a6193df3c4fe711f1bdfc6279a30896cff6ac01701d27c0ff9224e9782eddd1b4a47045a200e61e49fcc88e5acdb91036e5e4
7
+ data.tar.gz: bcb216c12079501fb0d9669fa71e04a5d81d28e09e40919dcd752cf23564f3906bf276863be1bd4fd51ec30aeb5f21d048002f6bce349e5f6ec8b4ee5cde5253
data/Cargo.lock CHANGED
@@ -220,9 +220,9 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
220
220
 
221
221
  [[package]]
222
222
  name = "comrak"
223
- version = "0.53.0"
223
+ version = "0.55.0"
224
224
  source = "registry+https://github.com/rust-lang/crates.io-index"
225
- checksum = "9795cb30f4deefbf33488819707e0f9630535dd56208ec273c1b3f150196377a"
225
+ checksum = "daa3d1ea6b01ce72405fa3f826768f51c7a44917527c89b37856ffdd17ee57e4"
226
226
  dependencies = [
227
227
  "caseless",
228
228
  "emojis",
@@ -328,7 +328,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
328
328
 
329
329
  [[package]]
330
330
  name = "gitlab-glfm-markdown"
331
- version = "0.0.42"
331
+ version = "0.0.43"
332
332
  dependencies = [
333
333
  "clap",
334
334
  "comrak",
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Latest Release](https://gitlab.com/gitlab-org/ruby/gems/gitlab-glfm-markdown/-/badges/release.svg)](https://gitlab.com/gitlab-org/ruby/gems/gitlab-glfm-markdown/-/releases)
5
5
 
6
6
  Implements GLFM (as used by GitLab) using the Rust-based Markdown parser
7
- [Comrak](https://github.com/kivikakk/comrak) (0.53.0), providing a Ruby interface.
7
+ [Comrak](https://github.com/kivikakk/comrak) (0.55.0), providing a Ruby interface.
8
8
 
9
9
  This project is still in constant flux, so interfaces and functionality can change at any time.
10
10
 
@@ -57,6 +57,7 @@ GLFMMarkdown.to_html('# header', options: { sourcepos: true })
57
57
  | `hardbreaks` | Treat newlines as hard line breaks |
58
58
  | `header_accessibility` | Use new header/anchor combination in HTML output, per [!112](https://gitlab.com/gitlab-org/ruby/gems/gitlab-glfm-markdown/-/merge_requests/112). Requires `header_id_prefix` to be set. |
59
59
  | `header_id_prefix <PREFIX>` | Enable the `header-id` extension, with the given ID prefix |
60
+ | `header_id_prefix_in_href` | Include `header_id_prefix` in the heading anchor's `href`. Requires `header_id_prefix` to be set. |
60
61
  | `header_slug_prefix <PREFIX>` | Prefix to prepend to heading anchor slugs. When set, slugs become `{header_slug_prefix}{anchorized_text}`. Requires `header_accessibility` to be set. |
61
62
  | `ignore_empty_links` | Ignore empty links in input |
62
63
  | `ignore_setext` | Ignore setext headings in input |
@@ -74,7 +75,6 @@ GLFMMarkdown.to_html('# header', options: { sourcepos: true })
74
75
  | `strikethrough` | Enable the `strikethrough` extension |
75
76
  | `superscript` | Enable the `superscript` extension |
76
77
  | `table` | Enable the `table` extension |
77
- | `tagfilter` | Enable the `tagfilter` extension |
78
78
  | `tasklist_classes` | Output classes on tasklist elements so that they can be styled with CSS |
79
79
  | `tasklist_in_table` | Enables parsing tasklist items within tables when they're the only content of a table cell |
80
80
  | `tasklist` | Enable the `tasklist` extension |
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "gitlab-glfm-markdown"
3
- version = "0.0.42"
3
+ version = "0.0.43"
4
4
  edition = "2021"
5
5
  authors = ["digitalmoksha <bwalker@gitlab.com>", "Asherah Connor <aconnor@gitlab.com>"]
6
6
  description = "GitLab Flavored Markdown parser and formatter. 100% CommonMark-compatible."
@@ -15,7 +15,7 @@ required-features = ["cli"]
15
15
 
16
16
  [dependencies]
17
17
  clap = { version = "=4.4.18", optional = true, features = ["derive", "string"] }
18
- comrak = { version = "0.53.0", default-features = false, features = ["shortcodes"] }
18
+ comrak = { version = "0.55.0", default-features = false, features = ["shortcodes"] }
19
19
  magnus = "0.8.2"
20
20
  rb-sys = { version = "0.9.124", default-features = false, features = ["stable-api-compiled-fallback"] }
21
21
  regex = "1.11.1"
@@ -1,7 +1,7 @@
1
1
  use std::fmt::{self, Write};
2
2
  use std::sync::LazyLock;
3
3
 
4
- use comrak::html::{collect_text, format_node_default, render_sourcepos, ChildRendering, Context};
4
+ use comrak::html::{format_node_default, render_sourcepos, ChildRendering, Context};
5
5
  use comrak::nodes::{
6
6
  ListType, NodeHeading, NodeLink, NodeList, NodeTaskItem, NodeValue, TableAlignment,
7
7
  };
@@ -487,7 +487,7 @@ fn render_heading(
487
487
  write!(context, "<h{}", nh.level)?;
488
488
 
489
489
  if let Some(ref prefix) = context.options.extension.header_id_prefix {
490
- let text_content = collect_text(node);
490
+ let text_content = node.collect_text();
491
491
  let id = context.anchorizer.anchorize(&text_content);
492
492
  let id = if let Some(ref slug_prefix) = context.user.header_slug_prefix {
493
493
  format!("{slug_prefix}{id}")
@@ -501,12 +501,17 @@ fn render_heading(
501
501
  render_sourcepos(context, node)?;
502
502
  context.write_str(">")?;
503
503
  } else {
504
- if context.options.extension.header_id_prefix.is_some() {
504
+ if let Some(ref prefix) = context.options.extension.header_id_prefix {
505
+ let href_prefix = if context.options.extension.header_id_prefix_in_href {
506
+ prefix.clone()
507
+ } else {
508
+ String::new()
509
+ };
505
510
  let id = context.user.last_heading.take().unwrap();
506
- let text_content = collect_text(node);
511
+ let text_content = node.collect_text();
507
512
  write!(
508
513
  context,
509
- r##"<a href="#{id}" aria-label="Link to heading '"##
514
+ r##"<a href="#{href_prefix}{id}" aria-label="Link to heading '"##
510
515
  )?;
511
516
  context.escape(&text_content)?;
512
517
  context.write_str(r#"'" data-heading-content=""#)?;
@@ -30,6 +30,8 @@ pub struct RenderOptions {
30
30
  /// Requires `header_id_prefix` to generate heading anchors.
31
31
  pub header_accessibility: bool,
32
32
  pub header_id_prefix: Option<String>,
33
+ /// Include `header_id_prefix` in the heading anchor's `href`.
34
+ pub header_id_prefix_in_href: bool,
33
35
  /// Prefix to prepend to heading anchor slugs.
34
36
  /// When set, slugs become `{header_slug_prefix}{anchorized_text}`.
35
37
  /// Requires `header_accessibility` to be set.
@@ -57,7 +59,6 @@ pub struct RenderOptions {
57
59
  pub superscript: bool,
58
60
  // pub syntax_highlighting: String,
59
61
  pub table: bool,
60
- pub tagfilter: bool,
61
62
  pub tasklist: bool,
62
63
  pub tasklist_classes: bool,
63
64
  pub tasklist_in_table: bool,
@@ -79,6 +80,7 @@ impl From<&RenderOptions> for comrak::Options<'_> {
79
80
  // comrak_options.extension.front_matter_delimiter = options.front_matter_delimiter;
80
81
  comrak_options.extension.greentext = options.greentext;
81
82
  comrak_options.extension.header_id_prefix = options.header_id_prefix.clone();
83
+ comrak_options.extension.header_id_prefix_in_href = options.header_id_prefix_in_href;
82
84
  comrak_options.extension.math_code = options.math_code;
83
85
  comrak_options.extension.math_dollars = options.math_dollars;
84
86
  comrak_options.extension.multiline_block_quotes = options.multiline_block_quotes;
@@ -88,7 +90,6 @@ impl From<&RenderOptions> for comrak::Options<'_> {
88
90
  comrak_options.extension.subscript = options.subscript;
89
91
  comrak_options.extension.superscript = options.superscript;
90
92
  comrak_options.extension.table = options.table;
91
- comrak_options.extension.tagfilter = options.tagfilter;
92
93
  comrak_options.extension.tasklist = options.tasklist;
93
94
  comrak_options.extension.underline = options.underline;
94
95
  comrak_options.extension.wikilinks_title_after_pipe = options.wikilinks_title_after_pipe;
@@ -93,6 +93,10 @@ struct Args {
93
93
  #[arg(long, value_name = "PREFIX")]
94
94
  header_id_prefix: Option<String>,
95
95
 
96
+ /// Include the header ID prefix in the heading anchor's href.
97
+ #[arg(long)]
98
+ header_id_prefix_in_href: bool,
99
+
96
100
  /// Prefix to prepend to heading anchor slugs.
97
101
  /// When set, slugs become `{header_slug_prefix}{anchorized_text}`.
98
102
  #[arg(long, value_name = "PREFIX")]
@@ -172,10 +176,6 @@ struct Args {
172
176
  #[arg(long)]
173
177
  table: bool,
174
178
 
175
- /// Enable 'tagfilter' extension
176
- #[arg(long)]
177
- tagfilter: bool,
178
-
179
179
  /// Enable 'tasklist' extension
180
180
  #[arg(long)]
181
181
  tasklist: bool,
@@ -239,6 +239,7 @@ fn main() {
239
239
  hardbreaks: cli.hardbreaks,
240
240
  header_accessibility: cli.header_accessibility,
241
241
  header_id_prefix: cli.header_id_prefix,
242
+ header_id_prefix_in_href: cli.header_id_prefix_in_href,
242
243
  header_slug_prefix: cli.header_slug_prefix,
243
244
  ignore_empty_links: cli.ignore_empty_links,
244
245
  ignore_setext: cli.ignore_setext,
@@ -258,7 +259,6 @@ fn main() {
258
259
  superscript: cli.superscript,
259
260
  // syntax_highlighting:
260
261
  table: cli.table,
261
- tagfilter: cli.tagfilter,
262
262
  tasklist: cli.tasklist,
263
263
  tasklist_classes: cli.tasklist_classes,
264
264
  tasklist_in_table: cli.tasklist_in_table,
@@ -24,7 +24,6 @@ module GLFMMarkdown
24
24
  smart: false,
25
25
  strikethrough: true,
26
26
  table: true,
27
- tagfilter: false,
28
27
  tasklist: true,
29
28
  tasklist_classes: true,
30
29
  unsafe: true
@@ -38,9 +37,6 @@ module GLFMMarkdown
38
37
 
39
38
  default_options = options[:glfm] ? GLFM_DEFAULT_OPTIONS : {}
40
39
 
41
- # if you need to modify `options`, use `.merge` as `options` could be frozen
42
- options = options.merge(unsafe: true) if options[:tagfilter]
43
-
44
40
  render_to_html_rs(markdown, default_options.merge(options))
45
41
  end
46
42
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GLFMMarkdown
4
- VERSION = '0.0.42'
4
+ VERSION = '0.0.43'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-glfm-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.42
4
+ version: 0.0.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Walker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2026-07-08 00:00:00.000000000 Z
12
+ date: 2026-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rb_sys