gitlab-glfm-markdown 0.0.33-aarch64-linux-gnu → 0.0.34-aarch64-linux-gnu

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: b106c214f8be8fe1bfe2d5318a63948b55f9af95fefcf1b5f44af16c23e24c94
4
- data.tar.gz: b7778354c35220d9017c75b7d1b4481afa6fef66e35cfac6ca3da5c6a86d47c0
3
+ metadata.gz: 191c73d9d22b15f326b0e617b1f87958a65365b87e7f0e116674d4afb3f2b9ae
4
+ data.tar.gz: 5f0166e25ac6636be7e645cbf768a6afd60c0a050524ca92c52ca2abcca8b3c5
5
5
  SHA512:
6
- metadata.gz: 98e42591c6bbb6071fd9546c76302cd2d1762e88c84fe96db7dc4cc579a709bd2f538b1dd6613e3a7a87465429838e4b73831978e2d7daece1b0bf4a87bb8994
7
- data.tar.gz: 512d1907ca7fc9d384963925d7760500763183e430880d6310b5a584b2bdb784a9f0d0b7513504d8f15f171eb0bfe1d840c1b5c7365ee2e4e6af73e16d383db1
6
+ metadata.gz: df800a76bbff0be7bfa89f06ab647f3649f69492359af170e74f8f2fae2ea8590d87858ac100cc26e594400390dba03d002edae78ac7941432122163b38622ac
7
+ data.tar.gz: ac222d8a0ac88176d26fd3b07683fa2624436b709d313ee2a2f331eb9c302c834f399ad8e3731784a94b9dfe83ffa38da16018c629560b9b15cf7f38ccfec173
data/Cargo.lock CHANGED
@@ -227,9 +227,9 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
227
227
 
228
228
  [[package]]
229
229
  name = "comrak"
230
- version = "0.40.0"
230
+ version = "0.41.1"
231
231
  source = "registry+https://github.com/rust-lang/crates.io-index"
232
- checksum = "32c3278f396e5707769a68bc0943e9b8f84a172836b173827810918279621747"
232
+ checksum = "9a45df55bc7f91b899160098a7c9b35d6e575dfb4fe22100f014b41a171af2c6"
233
233
  dependencies = [
234
234
  "caseless",
235
235
  "emojis",
@@ -320,7 +320,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
320
320
 
321
321
  [[package]]
322
322
  name = "glfm_markdown"
323
- version = "0.0.33"
323
+ version = "0.0.34"
324
324
  dependencies = [
325
325
  "clap",
326
326
  "comrak",
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Implements GLFM (as used by GitLab) using the Rust-based markdown parser [comrak](https://github.com/kivikakk/comrak)
7
7
  and providing a Ruby interface.\
8
- _Currently using `comrak 0.40.0`_.
8
+ _Currently using `comrak 0.41.1`_.
9
9
 
10
10
  This project is still in constant flux, so interfaces and functionality can change at any time.
11
11
 
@@ -95,7 +95,7 @@ of Ruby for the project and the gem. Otherwise you can see unexplained errors wh
95
95
  calling into the gem.
96
96
 
97
97
  NOTE: This project generates a changelog automatically that gets attached to the release entry.
98
- The normal [GitLab changelog entry process](https://docs.gitlab.com/ee/development/changelog.html)
98
+ The normal [GitLab changelog entry process](https://docs.gitlab.com/development/changelog.html)
99
99
  should be followed.
100
100
 
101
101
  ### Releasing a new version
@@ -227,9 +227,9 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
227
227
 
228
228
  [[package]]
229
229
  name = "comrak"
230
- version = "0.40.0"
230
+ version = "0.41.1"
231
231
  source = "registry+https://github.com/rust-lang/crates.io-index"
232
- checksum = "32c3278f396e5707769a68bc0943e9b8f84a172836b173827810918279621747"
232
+ checksum = "9a45df55bc7f91b899160098a7c9b35d6e575dfb4fe22100f014b41a171af2c6"
233
233
  dependencies = [
234
234
  "caseless",
235
235
  "emojis",
@@ -320,7 +320,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
320
320
 
321
321
  [[package]]
322
322
  name = "glfm_markdown"
323
- version = "0.0.33"
323
+ version = "0.0.34"
324
324
  dependencies = [
325
325
  "clap",
326
326
  "comrak",
@@ -1,8 +1,8 @@
1
1
  [package]
2
2
  name = "glfm_markdown"
3
- version = "0.0.33"
3
+ version = "0.0.34"
4
4
  edition = "2021"
5
- authors = ["digitalmoksha <bwalker@gitlab.com>"]
5
+ authors = ["digitalmoksha <bwalker@gitlab.com>", "Asherah Connor <aconnor@gitlab.com>"]
6
6
  description = "GitLab Flavored Markdown parser and formatter. 100% CommonMark-compatible. Experimental."
7
7
  publish = false
8
8
 
@@ -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.40.0", default-features = false, features = ["shortcodes"] }
18
+ comrak = { version = "0.41.1", default-features = false, features = ["shortcodes"] }
19
19
  magnus = "0.6.2"
20
20
  rb-sys = { version = "0.9.86", default-features = false, features = ["stable-api-compiled-fallback"] }
21
21
  regex = "1.11.1"
@@ -1,16 +1,16 @@
1
- use comrak::html::{ChildRendering, Context};
1
+ use std::io::{self, Write};
2
+
3
+ use comrak::html::{collect_text, format_node_default, render_sourcepos, ChildRendering, Context};
2
4
  use comrak::nodes::{AstNode, ListType, NodeValue};
3
5
  use comrak::{create_formatter, html, parse_document, Arena, Plugins};
4
6
  use lazy_static::lazy_static;
5
7
  use regex::Regex;
6
- use std::io;
7
- use std::io::{BufWriter, Write};
8
8
 
9
9
  lazy_static! {
10
10
  static ref PLACEHOLDER_REGEX: Regex = Regex::new(r"%(\{|%7B)(\w{1,30})(}|%7D)").unwrap();
11
11
  }
12
12
 
13
- #[derive(Debug, Clone)]
13
+ #[derive(Debug)]
14
14
  pub struct RenderOptions {
15
15
  pub alerts: bool,
16
16
  pub autolink: bool,
@@ -148,11 +148,11 @@ fn render_with_plugins(text: String, render_options: RenderOptions, plugins: &Pl
148
148
 
149
149
  let arena = Arena::new();
150
150
  let root = parse_document(&arena, &text, &options);
151
- let mut bw = BufWriter::new(Vec::new());
152
151
 
152
+ let mut bw = Vec::new();
153
153
  CustomFormatter::format_document_with_plugins(root, &options, &mut bw, plugins, user_data)
154
154
  .unwrap();
155
- String::from_utf8(bw.into_inner().unwrap()).unwrap()
155
+ String::from_utf8(bw).unwrap()
156
156
  }
157
157
 
158
158
  // The important thing to remember is that this overrides the default behavior of the
@@ -177,7 +177,10 @@ create_formatter!(CustomFormatter<RenderUserData>, {
177
177
  },
178
178
  NodeValue::TaskItem(_) => |context, node, entering| {
179
179
  return render_task_item(context, node, entering);
180
- }
180
+ },
181
+ NodeValue::Heading(_) => |context, node, entering| {
182
+ return render_heading(context, node, entering);
183
+ },
181
184
  });
182
185
 
183
186
  fn render_image<'a>(
@@ -186,7 +189,7 @@ fn render_image<'a>(
186
189
  entering: bool,
187
190
  ) -> io::Result<ChildRendering> {
188
191
  let NodeValue::Image(ref nl) = node.data.borrow().value else {
189
- panic!("Attempt to render invalid node as image")
192
+ unreachable!()
190
193
  };
191
194
 
192
195
  if !(context.user.placeholder_detection && PLACEHOLDER_REGEX.is_match(nl.url.as_str())) {
@@ -243,7 +246,7 @@ fn render_link<'a>(
243
246
  entering: bool,
244
247
  ) -> io::Result<ChildRendering> {
245
248
  let NodeValue::Link(ref nl) = node.data.borrow().value else {
246
- panic!("Attempt to render invalid node as link")
249
+ unreachable!()
247
250
  };
248
251
 
249
252
  if !(context.user.placeholder_detection && PLACEHOLDER_REGEX.is_match(nl.url.as_str())) {
@@ -303,7 +306,7 @@ fn render_list<'a>(
303
306
  }
304
307
 
305
308
  let NodeValue::List(ref nl) = node.data.borrow().value else {
306
- panic!("Attempt to render invalid node as list")
309
+ unreachable!()
307
310
  };
308
311
 
309
312
  context.cr()?;
@@ -344,7 +347,7 @@ fn render_task_item<'a>(
344
347
  }
345
348
 
346
349
  let NodeValue::TaskItem(symbol) = node.data.borrow().value else {
347
- panic!("Attempt to render invalid node as task item")
350
+ unreachable!()
348
351
  };
349
352
 
350
353
  if symbol.is_none() || matches!(symbol, Some('x' | 'X')) {
@@ -393,13 +396,14 @@ fn render_task_item<'a>(
393
396
 
394
397
  Ok(ChildRendering::HTML)
395
398
  }
399
+
396
400
  fn render_text<'a>(
397
401
  context: &mut Context<RenderUserData>,
398
402
  node: &'a AstNode<'a>,
399
403
  entering: bool,
400
404
  ) -> io::Result<ChildRendering> {
401
405
  let NodeValue::Text(ref literal) = node.data.borrow().value else {
402
- panic!("Attempt to render invalid node as text")
406
+ unreachable!()
403
407
  };
404
408
 
405
409
  if !(context.user.placeholder_detection && PLACEHOLDER_REGEX.is_match(literal)) {
@@ -441,3 +445,45 @@ fn render_text<'a>(
441
445
 
442
446
  Ok(ChildRendering::HTML)
443
447
  }
448
+
449
+ fn render_heading<'a>(
450
+ context: &mut Context<RenderUserData>,
451
+ node: &'a AstNode<'a>,
452
+ entering: bool,
453
+ ) -> io::Result<ChildRendering> {
454
+ let NodeValue::Heading(ref nh) = node.data.borrow().value else {
455
+ unreachable!()
456
+ };
457
+
458
+ match context.plugins.render.heading_adapter {
459
+ None => {
460
+ // Overrides the default handling in order to render the heading text
461
+ // inside the anchor tag to better support screen readers
462
+ if entering {
463
+ context.cr()?;
464
+ write!(context, "<h{}", nh.level)?;
465
+ render_sourcepos(context, node)?;
466
+ context.write_all(b">")?;
467
+
468
+ if let Some(ref prefix) = context.options.extension.header_ids {
469
+ let mut text_content = Vec::with_capacity(20);
470
+ collect_text(node, &mut text_content);
471
+
472
+ let mut id = String::from_utf8(text_content).unwrap();
473
+ id = context.anchorizer.anchorize(id);
474
+ write!(
475
+ context,
476
+ r##"<a href="#{id}" class="anchor" id="{prefix}{id}">"##
477
+ )?;
478
+ }
479
+ } else {
480
+ if context.options.extension.header_ids.is_some() {
481
+ write!(context, "</a>")?;
482
+ }
483
+ writeln!(context, "</h{}>", nh.level)?;
484
+ }
485
+ Ok(ChildRendering::HTML)
486
+ }
487
+ Some(_adapter) => format_node_default(context, node, entering),
488
+ }
489
+ }
Binary file
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GLFMMarkdown
4
- VERSION = '0.0.33'
4
+ VERSION = '0.0.34'
5
5
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-glfm-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33
4
+ version: 0.0.34
5
5
  platform: aarch64-linux-gnu
6
6
  authors:
7
7
  - Brett Walker
8
+ - Asherah Connor
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2025-07-23 00:00:00.000000000 Z
12
+ date: 2025-09-24 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rb_sys
@@ -55,6 +56,7 @@ dependencies:
55
56
  description: Markdown processing for GitLab Flavored Markdown
56
57
  email:
57
58
  - bwalker@gitlab.com
59
+ - aconnor@gitlab.com
58
60
  executables: []
59
61
  extensions: []
60
62
  extra_rdoc_files: []