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
43 changes: 20 additions & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ on:
# Only trigger when relevant code changes to save resources
paths:
- '.github/workflows/ci.yml'
- 'packages/linkify/**'
- 'packages/markdown-parser/**'
- 'packages/markdown-parser-rust/**'
- 'packages/markdown-parser-lit/**'
- 'packages/markdown-parser-vue/**'
- 'packages/playground/**'
- 'fixtures/**'
- 'crate/**'
- 'fixture/**'
- 'package/linkify/**'
- 'package/parser/**'
- 'package/lit-renderer**'
- 'package/vue-renderer/**'
- 'playground/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'package.json'
Expand All @@ -23,13 +23,13 @@ on:
pull_request:
paths:
- '.github/workflows/ci.yml'
- 'packages/linkify/**'
- 'packages/markdown-parser/**'
- 'packages/markdown-parser-rust/**'
- 'packages/markdown-parser-lit/**'
- 'packages/markdown-parser-vue/**'
- 'packages/playground/**'
- 'fixtures/**'
- 'crate/**'
- 'fixture/**'
- 'package/linkify/**'
- 'package/parser/**'
- 'package/lit-renderer**'
- 'package/vue-renderer/**'
- 'playground/**'
- 'Cargo.toml'
- 'Cargo.lock'
- 'package.json'
Expand All @@ -44,7 +44,6 @@ env:

jobs:
test-markdown-parser:
name: Test markdown parser
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -67,17 +66,15 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Build linkify package
run: pnpm --filter @fuyeor/linkify build
run: pnpm --filter @ffm/linkify build
- name: Typecheck parser package
run: pnpm --filter @fuyeor/markdown-parser typecheck
run: pnpm --filter @ffm/parser typecheck
- name: Run parser unit tests
run: pnpm --filter @fuyeor/markdown-parser test:unit
run: pnpm --filter @ffm/parser test:unit
- name: Run FFM regression tests
run: pnpm --filter @fuyeor/markdown-parser test:ffm
- name: Run safety fixtures
run: pnpm --filter @fuyeor/markdown-parser test:safety
- name: Run shared linkify fixtures
run: pnpm --filter @fuyeor/linkify exec vitest run src/cross-language-fixtures.spec.ts
run: pnpm --filter @ffm/parser test:ffm
- name: Run safety fixture
run: pnpm --filter @ffm/parser test:safety
- name: Check Rust parser
run: |
cargo fmt --all -- --check
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**/node_modules
**/dist
**/out
**/tests.failed.json
packages/playground/public/assets/locale/*
**/target
**/test.failed.json
**/target
playground/public/assets/locale/*
8 changes: 4 additions & 4 deletions .localerc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"basic": {
"source": "packages/playground/node_modules/@fuyeor/locale/src/common.json",
"outDir": "packages/playground/public/assets/locale"
"source": "package/playground/node_modules/@fuyeor/locale/src/common.json",
"outDir": "package/playground/public/assets/locale"
},
"main": {
"source": "packages/playground/src/locale/locale.json",
"outDir": "packages/playground/public/assets/locale"
"source": "package/playground/src/@app/locale.json",
"outDir": "package/playground/public/assets/locale"
}
}
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.formatOnSave": false,
"editor.formatOnType": false
},
"search.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/build": true
"**/build": true,
"**/target": true
}
}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# /Cargo.toml
[workspace]
members = ["packages/markdown-parser-rust"]
members = ["crate"]
resolver = "3"
22 changes: 12 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# monorepo/Dockerfile.frontend

# ==========================================
# build @fuyeor/markdown-parser-playground
# build @ffm/playground
# ==========================================
FROM node:24-slim AS builder
ENV PNPM_HOME="/pnpm"
Expand All @@ -13,27 +13,29 @@ WORKDIR /app

# prepare depends
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
# copy shared packages
COPY packages/linkify/package.json packages/linkify/
COPY packages/markdown-parser/package.json packages/markdown-parser/
COPY packages/markdown-parser-lit/package.json packages/markdown-parser-lit/
COPY packages/playground/package.json packages/playground/
# copy shared package
COPY package/converter/package.json package/converter/
COPY package/formatter/package.json package/formatter/
COPY package/linkify/package.json package/linkify/
COPY package/parser/package.json package/parser/
COPY package/vue-renderer/package.json package/vue-renderer/
COPY playground/package.json playground/

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile

# copy source code
COPY . .

# build linkify before parser consumers resolve its package exports
RUN pnpm --filter @fuyeor/linkify build
RUN pnpm --filter @ffm/linkify build
# build parser package before workspace consumers resolve its package exports
RUN pnpm --filter @fuyeor/markdown-parser build
RUN pnpm --filter @ffm/parser build

# generate production locale assets before the playground build copies public files
RUN pnpm locale make playground prod

# build playground
RUN pnpm --filter @fuyeor/markdown-playground build
RUN pnpm --filter @ffm/playground build

# ==========================================
# release
Expand All @@ -44,7 +46,7 @@ FROM nginx:alpine AS runner
RUN rm -rf /usr/share/nginx/html/*

# copy build artifacts
COPY --from=builder /app/packages/playground/dist /usr/share/nginx/html
COPY --from=builder /app/playground/dist /usr/share/nginx/html

# Nginx config
RUN echo 'server { \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# packages/markdown-parser-rust/Cargo.toml
[package]
name = "ffm-parser"
version = "0.1.0"
Expand Down
24 changes: 12 additions & 12 deletions packages/markdown-parser-rust/src/ast.rs → crate/src/ast.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// packages/markdown-parser-rust/src/ast.rs
// src/ast.rs
use std::collections::BTreeMap;

#[cfg(feature = "serde")]
Expand Down Expand Up @@ -128,10 +128,10 @@ impl Alignment {
pub struct AstNode {
/// The semantic node type.
pub node_type: NodeType,
/// Literal text or code content, when present.
pub content: Option<String>,
/// Literal text or code content value, when present.
pub value: Option<String>,
/// Child nodes in source order.
pub children: Vec<AstNode>,
pub content: Vec<AstNode>,
/// ATX heading level.
pub level: Option<u8>,
/// Fenced code info string.
Expand All @@ -143,7 +143,7 @@ pub struct AstNode {
/// Ordered-list starting number.
pub start: Option<u64>,
/// Table header cells.
pub headers: Option<Vec<AstNode>>,
pub header: Option<Vec<AstNode>>,
/// Accordion or chain group name.
pub name: Option<String>,
/// Accordion or chain item title nodes.
Expand All @@ -163,14 +163,14 @@ impl AstNode {
pub fn new(node_type: NodeType) -> Self {
Self {
node_type,
content: None,
children: Vec::new(),
value: None,
content: Vec::new(),
level: None,
lang: None,
url: None,
ordered: None,
start: None,
headers: None,
header: None,
name: None,
title: None,
is_completed: None,
Expand All @@ -181,16 +181,16 @@ impl AstNode {
}

/// Creates a text node with the supplied content.
pub fn text(content: impl Into<String>) -> Self {
pub fn text(value: impl Into<String>) -> Self {
let mut node = Self::new(NodeType::Text);
node.content = Some(content.into());
node.value = Some(value.into());
node
}

/// Creates a node with child nodes.
pub fn with_children(node_type: NodeType, children: Vec<AstNode>) -> Self {
pub fn with_content(node_type: NodeType, content: Vec<AstNode>) -> Self {
let mut node = Self::new(node_type);
node.children = children;
node.content = content;
node
}
}
Loading
Loading