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
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '22'

- name: JS 语法检查
run: node --check main.js

- name: 冒烟检查
run: node tests/smoke.mjs

- name: 导入、导出与编辑回归测试
run: node --test

# 纯静态项目无运行时依赖,无需安装
- name: 打包项目为 zip
shell: pwsh
Expand All @@ -22,6 +35,7 @@ jobs:
New-Item -ItemType Directory -Path $name -Force | Out-Null
Copy-Item index.html, style.css, main.js, LICENSE, README.md, README.en.md -Destination $name
Copy-Item screenshots -Destination $name -Recurse
Copy-Item tests -Destination $name -Recurse
Compress-Archive -Path $name -DestinationPath "$name.zip"

- name: 发布到 GitHub Release
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ name: CI

on:
push:
branches: [main]
branches: [main, dev]
pull_request:
branches: [main]
branches: [main, dev]

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'

# JS 语法检查(等效于 compileall)
- name: JS 语法检查
Expand All @@ -19,3 +22,6 @@ jobs:
# 无头冒烟检查:资源完整、标签配对、DOM id 一致性
- name: 冒烟检查
run: node tests/smoke.mjs

- name: 导入、导出与编辑回归测试
run: node --test
10 changes: 10 additions & 0 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ jobs:
- name: 检出代码
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '22'

- name: 验证待部署的同一提交
run: |
node --check main.js
node tests/smoke.mjs
node --test

- name: 配置 Pages
uses: actions/configure-pages@v5

Expand Down
28 changes: 19 additions & 9 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# VisualLaTeX

**Import · Tweak · Export — an offline LaTeX light editor that never loses a character**
**Import · Tweak · Export — an offline LaTeX light editor that preserves original source**

[![Version](https://img.shields.io/badge/Version-v2.0.2-6f42c1)](https://github.com/Escap1ng/VisualLaTeX/releases)
[![License](https://img.shields.io/badge/License-Apache_2.0-0366d6)](./LICENSE)
Expand Down Expand Up @@ -38,7 +38,7 @@ It's the night before the deadline, and your advisor only asked you to "change a

**Import `.tex` → light visual edits → export `.tex`**

Changes only happen where you make them; everything else is preserved character-for-character, fully offline.
Unedited source blocks retain their original comments, whitespace, and line endings. Edited regions are regenerated as LaTeX. Structures that cannot be safely converted stay in editable source blocks, fully offline.

## Features

Expand All @@ -47,7 +47,7 @@ Changes only happen where you make them; everything else is preserved character-
| One-click import | Open a local `.tex`; sections, paragraphs, lists, formulas, and images become visual elements |
| Split-pane view | Visual editor on the left, live LaTeX source preview on the right |
| Basic formatting | Three heading levels, bold, italic, center, ordered/unordered lists |
| Formula input | 30+ symbol quick palette, inline `$...$` and display `$$...$$` math |
| Formula input | 30+ symbols; `$...$`, `$$...$$`, `\(...\)`, and `\[...\]`; double-click visual formulas to edit |
| Verbatim blocks | Tables, bibliographies, code listings shown as-is, editable, never lost on export |
| Command protection | `\cite`, `\ref`, and other reference commands preserved verbatim |
| Image insertion | Enter a path to generate the `figure` float environment |
Expand All @@ -73,7 +73,7 @@ VisualLaTeX/
├── index.html # Main page (layout, toolbar)
├── style.css # Global styles
├── main.js # Editor core, .tex parsing, DOM↔LaTeX conversion
├── tests/ # Zero-dependency smoke checks (used by CI)
├── tests/ # Zero-dependency smoke and import/export/editing regression checks
├── .github/ # GitHub Actions workflows (CI / release / Pages)
├── README.md # Docs (Chinese)
└── README.en.md # Docs (English)
Expand All @@ -85,9 +85,19 @@ Automation is powered by GitHub Actions:

| Workflow | Trigger | Purpose |
|:---|:---|:---|
| CI | push to `main` / PR to `main` | JS syntax check + zero-dependency smoke checks (assets, tag pairing, DOM id consistency) |
| Build & Release | push `v*` version tag | Package `VisualLaTeX-vX.Y.Z.zip` and auto-upload to GitHub Release |
| Deploy to GitHub Pages | push to `main` | Auto-deploy the [online demo](https://Escap1ng.github.io/VisualLaTeX/) |
| CI | push or PR to `main` or `dev` | Syntax, asset integrity, and import/export/editing regression tests |
| Build & Release | push `v*` version tag | Package and release only after checks pass on that commit |
| Deploy to GitHub Pages | push to `main` | Deploy the [online demo](https://Escap1ng.github.io/VisualLaTeX/) only after checks pass on that commit |

Run locally with Node.js 22+; no npm packages are needed:

```bash
node --check main.js
node tests/smoke.mjs
node --test
```

Regression checks cover HTML injection, source round trips, local edits, formulas, images, escaping, and draft recovery. DOM checks use a minimal model; they do not replace real browser interaction or TeX compilation tests.

## Recommended Workflow

Expand All @@ -96,9 +106,9 @@ Import the `.tex` you want to touch up → make visual text and structure adjust
<details>
<summary><b>Known Limitations</b></summary>

1. Built on `contenteditable` for simplicity; complex nested layouts may parse incorrectly
1. Built on `contenteditable`; complex editing behavior still needs validation in individual browsers
2. No visual table editing (tables are edited as source inside verbatim blocks)
3. Edge cases such as nested same-name environments (e.g., itemize inside itemize) may not parse perfectly
3. Complex/nested environments, multiple images, custom list labels, and `equation` environments use editable source blocks; TeX macros are not expanded
4. This is a light editing tool; for large-scale rewrites, use a code editor

</details>
Expand Down
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# VisualLaTeX

**导入 · 轻改 · 导出 —— 一个字符都不丢的离线 LaTeX 轻编辑器**
**导入 · 轻改 · 导出 —— 保留原文的离线 LaTeX 轻编辑器**

[![Version](https://img.shields.io/badge/Version-v2.0.2-6f42c1)](https://github.com/Escap1ng/VisualLaTeX/releases)
[![License](https://img.shields.io/badge/License-Apache_2.0-0366d6)](./LICENSE)
Expand Down Expand Up @@ -31,14 +31,14 @@
| 场景 | 传统代码编辑器 | VisualLaTeX |
|:---|:---|:---|
| 小改动效率 | 在源码中手动定位结构 | 所见即所得,直接点改 |
| 误改风险 | 容易碰坏命令与环境 | 复杂结构原样锁存,零风险 |
| 误改风险 | 容易碰坏命令与环境 | 未编辑的源码块保留原文,复杂结构使用原文块 |
| 上手成本 | 需熟悉 LaTeX 语法 | 会用 Word 就会用 |

## 核心工作流

**导入 `.tex` → 可视化轻改 → 导出 `.tex`**

修改只发生在你改动的地方,其余内容逐字符原样保留,全程离线。
未编辑的源码块按原文保留,包括注释、空白与换行;编辑过的区段重新生成 LaTeX。无法安全转换的结构以可编辑原文块保留,全程离线。

## 功能一览

Expand All @@ -47,7 +47,7 @@
| 一键导入 | 打开本地 `.tex`,章节、段落、列表、公式、图片自动转为可视化元素 |
| 双栏同屏 | 左侧可视化编辑,右侧 LaTeX 源码实时预览 |
| 基础排版 | 三级标题、加粗、斜体、居中、有序/无序列表 |
| 公式输入 | 30+ 符号快捷面板,支持行内 `$...$` 与行间 `$$...$$` |
| 公式输入 | 30+ 符号快捷面板,支持 `$...$`、`$$...$$`、`\(...\)`、`\[...\]`;双击已有可视化公式可修改 |
| 原样保留块 | 表格、参考文献、代码清单等复杂结构原文展示、可编辑、导出不丢失 |
| 命令保护 | `\cite`、`\ref` 等引用命令原样保留,绝不被转义破坏 |
| 图片插入 | 填写路径自动生成 `figure` 浮动环境 |
Expand All @@ -73,7 +73,7 @@ VisualLaTeX/
├── index.html # 主页面(布局、工具栏)
├── style.css # 全局样式
├── main.js # 编辑器核心、.tex 解析、DOM↔LaTeX 转换
├── tests/ # 零依赖冒烟检查(CI 使用)
├── tests/ # 零依赖冒烟检查与导入/导出/编辑回归测试
├── .github/ # GitHub Actions 工作流(CI / 自动发布 / Pages 部署)
├── README.md # 项目说明(中文)
└── README.en.md # 项目说明(English)
Expand All @@ -85,9 +85,19 @@ VisualLaTeX/

| 工作流 | 触发时机 | 作用 |
|:---|:---|:---|
| CI | 推送 `main` / 针对 `main` 的 PR | JS 语法检查 + 零依赖冒烟检查(资源完整、标签配对、DOM id 一致性) |
| Build & Release | 推送 `v*` 版本标签 | 打包 `VisualLaTeX-vX.Y.Z.zip` 并自动上传至 GitHub Release |
| Deploy to GitHub Pages | 推送 `main` | 自动部署[在线预览版](https://Escap1ng.github.io/VisualLaTeX/) |
| CI | 推送 `main`、`dev` / 针对这两个分支的 PR | JS 语法、资源完整性及导入/导出/编辑回归测试 |
| Build & Release | 推送 `v*` 版本标签 | 同一提交检查通过后打包并上传 GitHub Release |
| Deploy to GitHub Pages | 推送 `main` | 同一提交检查通过后部署[在线预览版](https://Escap1ng.github.io/VisualLaTeX/) |

本地验证(Node.js 22+,无需安装 npm 包):

```bash
node --check main.js
node tests/smoke.mjs
node --test
```

回归测试覆盖 HTML 注入防护、源码往返、局部编辑、公式、图片、转义字符及草稿恢复。DOM 测试使用最小模型,不替代真实浏览器交互或 TeX 编译验证。

## 推荐工作流

Expand All @@ -96,9 +106,9 @@ VisualLaTeX/
<details>
<summary><b>已知限制</b></summary>

1. 基于 `contenteditable` 简易富文本实现,复杂嵌套排版容易解析出错
1. 基于 `contenteditable`,不同浏览器的复杂编辑行为仍需实际验证
2. 不支持可视化表格编辑(表格以原样保留块形式编辑源码)
3. 嵌套同名环境(如 itemize 套 itemize)等极端结构可能解析不完美
3. 复杂/嵌套环境、多图、带自定义标签的列表及 `equation` 环境以原文块编辑;不执行 TeX 宏展开
4. 定位是轻量修改工具,大规模重写建议直接使用代码编辑器

</details>
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h1>欢迎使用 VisualLaTeX</h1>
<h2>三步上手</h2>
<ol>
<li>点击工具栏的「导入 .tex」,选择本地的 LaTeX 文件</li>
<li>在左侧像使用 Word 一样修改文字、标题、列表与公式</li>
<li>在左侧修改文字、标题与列表,双击已有公式可打开编辑</li>
<li>点击「下载文件」导出修改后的 .tex,或复制代码到剪贴板</li>
</ol>

Expand Down
Loading