• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A Markdown shard for the Crystal programming language


コミットメタ情報

リビジョン896e7a1f46f7395dadd84d785816683a843e6909 (tree)
日時2023-10-26 12:18:37
作者supercell <stigma@disr...>
コミッターsupercell

ログメッセージ

Small style changes and documentation fixes

変更サマリ

差分

--- a/src/luce.cr
+++ b/src/luce.cr
@@ -64,15 +64,18 @@ require "./extern/dart_uri"
6464 # If you are only interested in rendering Markdown to HTML, please refer
6565 # to the [README](../index.html) which explains the use of `Luce.to_html`.
6666 #
67-# The main entrypoint to the library is the `Document` which encapsulates the
68-# parsing process converting a Markdown text into a tree of `Node` (`Array(Node)`).
67+# The main entrypoint to the library is the `Document` which
68+# encapsulates the parsing process converting a Markdown text into
69+# a tree of `Node` (`Array(Node)`).
6970 #
70-# Two main parsing mechanics are used:
71+# The two main parsing mechanics used are:
7172 #
72-# - Blocks, representing top level elements like: headers, paragraphs, blockquotes,
73-# code blocks, ... implemented via `BlockSyntax` subclasses.
74-# - Inlines, representing chunks of test within a block with special meaning, like:
75-# links, emphasis, inlined code, ... implemented via `InlineSyntax` subclasses.
73+# - Blocks, representing top-level elements
74+# implemented via `BlockSyntax` subclasses,
75+# such as headers, paragraphs, blockquotes, and code blocks.
76+# - Inlines, representing chunks of test within a block with special meaning,
77+# implemented via `InlineSyntax` subclasses,
78+# such as links, emphasis, and inlined code.
7679 #
7780 # Looking closely at `Document.new()` a few other concepts merit a mention:
7881 #
@@ -80,12 +83,13 @@ require "./extern/dart_uri"
8083 # - `Resolver` which aid in resolving links and images.
8184 #
8285 # If you are looking at extending the library to support custom formatting
83-# what you may want is to:
86+# what you might want is to:
8487 #
8588 # - Implement your own `InlineSyntax` subclasses
8689 # - Implement your own `BlockSyntax` subclasses
8790 # - Instruct the library to use those by:
88-# - Creating a new `ExtensionSet` from one of the existing flavors adding your syntaxes
91+# - Creating a new `ExtensionSet` from one of the existing flavors
92+# and adding your syntaxes.
8993 # - Passing your syntaxes to `Document` or `Luce.to_html` as parameters.
9094 module Luce
9195 VERSION = "0.4.0"
--- a/src/luce/block_syntaxes/code_block_syntax.cr
+++ b/src/luce/block_syntaxes/code_block_syntax.cr
@@ -21,7 +21,7 @@ module Luce
2121 until parser.done?
2222 is_blank_line = parser.current.is_blank_line?
2323 break if is_blank_line && should_end?(parser)
24- break if !is_blank_line && !child_lines.empty? && pattern.matches?(parser.current.content) != true
24+ break if !is_blank_line && !child_lines.empty? && !pattern.matches?(parser.current.content)
2525
2626 child_lines << Line.new(
2727 parser.current.content.dedent.text,
@@ -56,7 +56,7 @@ module Luce
5656 next
5757 end
5858
59- return pattern.matches?(next_line.content) == false
59+ return !pattern.matches?(next_line.content)
6060 end
6161 end
6262 end
--- a/src/luce/block_syntaxes/footnote_def_syntax.cr
+++ b/src/luce/block_syntaxes/footnote_def_syntax.cr
@@ -71,7 +71,8 @@ module Luce
7171 children.map { |e| Line.new(e) }
7272 end
7373
74- # Whether this line is one kind of block, if true footnotes block should end.
74+ # Whether this line is any kind of block.
75+ # If `true`, the footnote block should end.
7576 private def _is_block?(syntax_list : Array(BlockSyntax), line : String) : Bool
7677 syntax_list.any?(&.pattern.matches?(line))
7778 end
--- a/src/luce/document.cr
+++ b/src/luce/document.cr
@@ -9,10 +9,12 @@ module Luce
99 class Document
1010 getter link_references = Hash(String, LinkReference).new
1111
12- # Footnote ref count, keys are case-sensitive and added by define syntax
12+ # Footnote ref count, keys are case-sensitive and added by define syntax.
1313 getter footnote_references = Hash(String, Int32).new
1414
15- # Footnotes label by appearing order, are case-sensitive and added by ref syntax
15+ # Footnotes label by appearing order.
16+ #
17+ # They are case-sensitive and added by ref syntax.
1618 getter footnote_labels = [] of String
1719
1820 getter link_resolver : Resolver?
@@ -208,7 +210,8 @@ module Luce
208210 Text.new("\u21a9"),
209211 ] of Node)
210212 end
211- # Ignore GFM's attributes: <data-footnote-backref aria-label="Back to content">.
213+ # Ignore GFM's attributes:
214+ # <data-footnote-backref aria-label="Back to content">.
212215 ret.attributes["href"] = "#fnref-#{ref}#{suffix}"
213216 ret.attributes["class"] = "footnote-backref"
214217 ret
--- a/src/luce/inline_syntaxes/footnote_ref_syntax.cr
+++ b/src/luce/inline_syntaxes/footnote_ref_syntax.cr
@@ -5,10 +5,13 @@
55 #
66
77 module Luce
8- # The spec of GFM about footnotes is [missing](https://github.com/github/cmark-gfm/issues/283#issuecomment-1378868725).
9- # For source code of cmark-gfm, See [noMatch] label of [handle_close_bracket] function in [master@c32ef78](https://github.com/github/cmark-gfm/blob/c32ef78/src/inlines.c#L1236).
8+ # The spec of GFM about footnotes is
9+ # [missing](https://github.com/github/cmark-gfm/issues/283#issuecomment-1378868725).
10+ # For source code of cmark-gfm, See `noMatch` label of
11+ # `handle_close_bracket` function in [master@c32ef78](https://github.com/github/cmark-gfm/blob/c32ef78/src/inlines.c#L1236).
1012 # A Rust implementation is also [available](https://github.com/wooorm/markdown-rs/blob/2498e31eecead798efc649502bbf5f86feaa94be/src/construct/gfm_label_start_footnote.rs).
11- # Footnote shares the same syntax with `LinkSyntax`, but goes a different branch of handling close bracket.
13+ # Footnote shares the same syntax with `LinkSyntax`,
14+ # but have a different branch of handling close bracket.
1215 class FootnoteRefSyntax
1316 private def self.footnote_label(key : String) : String?
1417 return nil if key.empty? || key.codepoint_at(0) != Charcode::CARET
--- a/src/luce/text_parser.cr
+++ b/src/luce/text_parser.cr
@@ -42,7 +42,7 @@ module Luce
4242 char != Charcode::VT &&
4343 char != Charcode::CR &&
4444 char != Charcode::FF &&
45- !(multiline == true && char == Charcode::LF)
45+ !(multiline && char == Charcode::LF)
4646 return i
4747 end
4848