Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install MoonBit
# if: ${{ matrix.os.name != 'windows-latest' }}
run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s -- pre-release
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s
echo "$HOME/.moon/bin" >> $GITHUB_PATH

- name: Run benchmark
Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ jobs:
matrix:
os:
- name: ubuntu-latest
path: ubuntu_x86_64_moon_setup
- name: macos-13
path: mac_intel_moon_setup
- name: macos-latest
path: mac_m1_moon_setup
- name: windows-latest

runs-on: ${{ matrix.os.name }}
Expand All @@ -29,12 +25,10 @@ jobs:
- name: install
if: ${{ matrix.os.name != 'windows-latest' }}
run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s -- pre-release
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s
echo "$HOME/.moon/bin" >> $GITHUB_PATH

- name: install on windows
env:
MOONBIT_INSTALL_VERSION: pre-release
if: ${{ matrix.os.name == 'windows-latest' }}
run: |
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser; irm https://cli.moonbitlang.com/install/powershell.ps1 | iex
Expand All @@ -48,7 +42,8 @@ jobs:
- name: moon check
run: |
moon update
moon check --deny-warn
# moon check --deny-warn
moon check

- name: moon info and moon fmt
run: |
Expand All @@ -64,8 +59,10 @@ jobs:
moon test --target wasm --release
moon test --target wasm-gc
moon test --target wasm-gc --release
# moon test --target js
# moon test --target js --release
moon test --target js
moon test --target js --release
moon test --target native
moon test --target native --release

coverage-check:
runs-on: ubuntu-latest
Expand All @@ -75,7 +72,7 @@ jobs:

- name: install
run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s -- pre-release
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash -s
echo "$HOME/.moon/bin" >> $GITHUB_PATH

- name: moon test
Expand Down
3 changes: 2 additions & 1 deletion src/char/entities.mbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
///| A collection of named entities in HTML,
///|
/// A collection of named entities in HTML,
/// generated from <https://html.spec.whatwg.org/entities.json>.
/// To regenerate, run `moon build`.
let html_named_entities : Json = {
Expand Down
60 changes: 60 additions & 0 deletions src/char/pkg.generated.mbti
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Generated using `moon info`, DON'T EDIT IT
package "rami3l/cmark/char"

import(
"moonbitlang/core/string"
)

// Values
fn ascii_digit_to_int(Char) -> Int

fn ascii_hexdigit_to_int(Char) -> Int

fn ascii_octdigit_to_int(Char) -> Int

fn at_checked(@string.View, Int) -> Result[Char, Int]

fn is_ascii_alphanum(Char) -> Bool

fn is_ascii_blank(Char) -> Bool

fn is_ascii_control(Char) -> Bool

fn is_ascii_graphic(Char) -> Bool

fn is_ascii_punctuation(Char) -> Bool

fn is_ascii_whitespace(Char) -> Bool

fn length_utf16(Int) -> Int

fn length_utf32(Int) -> Int

fn length_utf8(Int) -> Int

fn next_char(@string.View, last~ : Int, after~ : Int) -> Char

fn prev_char(@string.View, first~ : Int, before~ : Int) -> Char

let rep : Char

fn sub_includes(affix~ : String, String, first~ : Int, last~ : Int) -> Bool

fn to_ascii_lower(Char) -> Char

fn to_ascii_upper(Char) -> Char

fn utf_16_clean_raw(pad? : Int, StringBuilder, String, first~ : Int, last~ : Int) -> String

fn utf_16_clean_unesc_unref(StringBuilder, String, first~ : Int, last~ : Int) -> String

fn utf_16_clean_unref(StringBuilder, String, first~ : Int, last~ : Int) -> String

// Errors

// Types and methods

// Type aliases

// Traits

2 changes: 1 addition & 1 deletion src/char/text.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn next_char(s : @string.View, last~ : Int, after~ : Int) -> Char {

///|
pub fn utf_16_clean_raw(
pad~ : Int = 0,
pad? : Int = 0,
buf : Buffer,
s : String,
first~ : Int,
Expand Down
4 changes: 2 additions & 2 deletions src/cmark/alias.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ typealias @cmark_base.Span
typealias @cmark_base.LineSpan

///|
priv struct Tokens(@deque.T[Token])
priv struct Tokens(@deque.Deque[Token])

///|
impl Show for Tokens with output(self, logger) {
Expand Down Expand Up @@ -58,7 +58,7 @@ fn Tokens::push(self : Tokens, t : Token) -> Unit {
// }

///|
priv struct RevTokens(@deque.T[Token])
priv struct RevTokens(@deque.Deque[Token])

///|
impl Show for RevTokens with output(self, logger) {
Expand Down
69 changes: 41 additions & 28 deletions src/cmark/block.mbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
///| A markdown block.
///|
/// A markdown block.
pub(all) enum Block {
BlankLine(Node[BlockBlankLine])
BlockQuote(Node[BlockQuote])
Expand Down Expand Up @@ -39,7 +40,8 @@ pub fn Block::meta(self : Block) -> Meta {
}
}

///| Normalize a block.
///|
/// Normalize a block.
///
/// `b.normalize()` has the same content as `b` but is such that for any
/// occurrence of `Blocks` in `b` the list of blocks `bs`:
Expand Down Expand Up @@ -71,11 +73,12 @@ pub fn Block::normalize(self : Block) -> Block {
}
}

///| Collects the given `Block`'s link definitions (e.g. `LinkRefDefinition`
///|
/// Collects the given `Block`'s link definitions (e.g. `LinkRefDefinition`
/// and `ExtFootnoteDefinition`) and adds them to `init` (defaults to an empty map).
pub fn Block::defs(
self : Block,
init~ : LabelDefs = LabelDefs::new(),
init? : LabelDefs = LabelDefs::new(),
) -> LabelDefs {
match self {
BlockQuote(bl) => bl.v.block.defs(init~)
Expand All @@ -95,11 +98,13 @@ pub fn Block::defs(
}
}

///| The type for [blank lines](https://spec.commonmark.org/0.30/#blank-lines).
///|
/// The type for [blank lines](https://spec.commonmark.org/0.30/#blank-lines).
/// These can be ignored during rendering, they are kept for layout.
pub typealias Blanks as BlockBlankLine

///| The type for [block quotes](https://spec.commonmark.org/0.30/#block-quotes).
///|
/// The type for [block quotes](https://spec.commonmark.org/0.30/#block-quotes).
pub(all) struct BlockQuote {
/// The indentation to the block quote marker found on the first line.
indent : Indent
Expand All @@ -108,7 +113,7 @@ pub(all) struct BlockQuote {
} derive(Show, ToJson)

///|
pub fn BlockQuote::new(indent~ : Int = 0, block : Block) -> BlockQuote {
pub fn BlockQuote::new(indent? : Int = 0, block : Block) -> BlockQuote {
{ indent, block }
}

Expand All @@ -125,7 +130,8 @@ pub fn BlockQuote::normalize_block(self : BlockQuote) -> BlockQuote {
self.map_block(Block::normalize)
}

///| The type for [indented](https://spec.commonmark.org/0.30/#indented-code-block) and
///|
/// The type for [indented](https://spec.commonmark.org/0.30/#indented-code-block) and
/// [fenced](:https://spec.commonmark.org/0.30/#fenced-code-blocks) code blocks.
pub(all) struct CodeBlock {
layout : CodeBlockLayout
Expand Down Expand Up @@ -153,8 +159,8 @@ pub fn CodeBlockFencedLayout::default() -> CodeBlockFencedLayout {

///|
pub fn CodeBlock::new(
layout~ : CodeBlockLayout = Fenced(CodeBlockFencedLayout::default()),
info_string~ : StringNode? = None,
layout? : CodeBlockLayout = Fenced(CodeBlockFencedLayout::default()),
info_string? : StringNode? = None,
code : Seq[StringNode],
) -> CodeBlock {
let layout = match (info_string, layout) {
Expand All @@ -165,7 +171,8 @@ pub fn CodeBlock::new(
{ layout, info_string, code }
}

///| [make_fence cb] is a fence character and count suitable for [cb].
///|
/// [make_fence cb] is a fence character and count suitable for [cb].
pub fn CodeBlock::make_fence(self : CodeBlock) -> (Char, Count) {
let ch = if self.info_string is Some(info) && info.v.contains_char('`') {
'~'
Expand All @@ -186,7 +193,8 @@ pub fn CodeBlock::make_fence(self : CodeBlock) -> (Char, Count) {
(ch, InlineCodeSpan::min_backticks(min=3, counts))
}

///| [language_of_info_string s] extracts a (non-empty) language, the first word of [s] and a trimmed remainder.
///|
/// [language_of_info_string s] extracts a (non-empty) language, the first word of [s] and a trimmed remainder.
/// Assumes [s] is {!String.trim}ed which is what {!info_string} gives you.
pub fn CodeBlock::language_of_info_string(s : String) -> (String, String)? {
guard not(s.is_empty()) else { None }
Expand All @@ -208,7 +216,8 @@ fn CodeBlock::is_math_block(s : String?) -> Bool {
CodeBlock::language_of_info_string(s).map(fn(i) { i.0 }) == Some("math")
}

///| The type for [ATX](https://spec.commonmark.org/0.30/#atx-headings)
///|
/// The type for [ATX](https://spec.commonmark.org/0.30/#atx-headings)
/// and [Setext](https://spec.commonmark.org/0.30/#setext-headings) headings.
pub(all) struct BlockHeading {
layout : BlockHeadingLayout
Expand Down Expand Up @@ -252,15 +261,16 @@ pub(all) enum BlockHeadingId {

///|
pub fn BlockHeading::new(
id~ : BlockHeadingId? = None,
layout~ : BlockHeadingLayout = Atx(BlockHeadingAtxLayout::default()),
id? : BlockHeadingId? = None,
layout? : BlockHeadingLayout = Atx(BlockHeadingAtxLayout::default()),
level~ : Int,
inline : Inline,
) -> BlockHeading {
{ layout, level, inline, id }
}

///| The type for [HTML blocks](https://spec.commonmark.org/0.30/#html-blocks).
///|
/// The type for [HTML blocks](https://spec.commonmark.org/0.30/#html-blocks).
pub(all) struct HtmlBlock(Seq[StringNode]) derive(Show, ToJson)

///|
Expand All @@ -277,9 +287,9 @@ pub typealias ListItem as ListItemBlock

///|
pub fn ListItem::new(
before_marker~ : Indent = 0,
marker~ : StringNode = layout_empty,
after_marker~ : Indent = 1,
before_marker? : Indent = 0,
marker? : StringNode = layout_empty,
after_marker? : Indent = 1,
ext_task_marker~ : Node[Char]?,
block : Block,
) -> ListItem {
Expand Down Expand Up @@ -314,7 +324,8 @@ pub fn ListTaskStatus::from_marker(marker : Char) -> ListTaskStatus {
}
}

///| The type for [lists](https://spec.commonmark.org/0.30/#lists).
///|
/// The type for [lists](https://spec.commonmark.org/0.30/#lists).
pub(all) struct BlockList {
ty : ListType
tight : Bool
Expand All @@ -334,7 +345,8 @@ pub fn BlockList::normalize_items(self : BlockList) -> BlockList {
self.map_items(ListItem::normalize_block)
}

///| The type for [paragraphs](https://spec.commonmark.org/0.30/#paragraphs).
///|
/// The type for [paragraphs](https://spec.commonmark.org/0.30/#paragraphs).
pub(all) struct BlockParagraph {
leading_indent : Indent
inline : Inline
Expand All @@ -343,23 +355,24 @@ pub(all) struct BlockParagraph {

///|
pub fn BlockParagraph::new(
leading_indent~ : Indent = 0,
trailing_blanks~ : Blanks = "",
leading_indent? : Indent = 0,
trailing_blanks? : Blanks = "",
inline : Inline,
) -> BlockParagraph {
{ leading_indent, inline, trailing_blanks }
}

///| The type for [thematic breaks](https://spec.commonmark.org/0.30/#thematic-break).
///|
/// The type for [thematic breaks](https://spec.commonmark.org/0.30/#thematic-break).
pub(all) struct BlockThematicBreak {
indent : Indent
layout : String
} derive(Show, FromJson, ToJson)

///|
pub fn BlockThematicBreak::new(
indent~ : Indent = 0,
layout~ : String = "---",
indent? : Indent = 0,
layout? : String = "---",
) -> BlockThematicBreak {
{ indent, layout }
}
Expand All @@ -376,7 +389,7 @@ pub(all) struct Footnote {

///|
pub fn Footnote::new(
indent~ : Indent = 0,
indent? : Indent = 0,
defined_label? : Label?,
label : Label,
block : Block,
Expand Down Expand Up @@ -436,7 +449,7 @@ pub(all) struct TableCellLayout((Blanks, Blanks)) derive (

///|
pub fn Table::new(
indent~ : Indent = 0,
indent? : Indent = 0,
rows : Seq[(Node[TableRow], Blanks)],
) -> Table {
let mut col_count = 0
Expand Down
Loading
Loading