freemd 0.1.0 → 0.1.1
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.
- package/README.es.md +3 -1
- package/README.md +3 -1
- package/package.json +1 -1
- package/server/export/highlight.js +25 -8
package/README.es.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[English](./README.md) · **Español**
|
|
4
4
|
|
|
5
|
-
Una app de notas en markdown *local
|
|
5
|
+
Una app de notas en markdown *local* que vive en tu máquina. Un comando y estás editando notas en tu navegador — interfaz dark limpia, vista previa en vivo, imágenes por nota que se pueden agregar desde el portapapeles y exportación a PDF o Word en un click.
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npx freemd
|
|
@@ -10,6 +10,8 @@ npx freemd
|
|
|
10
10
|
|
|
11
11
|
Eso es todo: crea `~/freemd` si no existe, levanta un servidor local en [http://localhost:5813](http://localhost:5813) y abre tu navegador.
|
|
12
12
|
|
|
13
|
+
<img src="./doc/img1.jpg" alt="img1" width="800">
|
|
14
|
+
|
|
13
15
|
## Por qué freemd
|
|
14
16
|
|
|
15
17
|
- **Tus notas son archivos simples.** Todo es markdown en tu propio disco: sin cuentas, sin nube, sin ataduras. Puedes respaldarlas, sincronizarlas o buscarlas con grep.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**English** · [Español](./README.es.md)
|
|
4
4
|
|
|
5
|
-
A local
|
|
5
|
+
A *local* Markdown notes app that lives on your machine. One command and you're editing notes in your browser — a clean dark interface, live preview, per-note images you can paste directly from your clipboard, and one-click export to PDF or Word.
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npx freemd
|
|
@@ -10,6 +10,8 @@ npx freemd
|
|
|
10
10
|
|
|
11
11
|
That's it: it creates `~/freemd` if it doesn't exist, starts a local server at [http://localhost:5813](http://localhost:5813) and opens your browser.
|
|
12
12
|
|
|
13
|
+
<img src="./doc/img1.jpg" alt="img1" width="800">
|
|
14
|
+
|
|
13
15
|
## Why freemd
|
|
14
16
|
|
|
15
17
|
- **Your notes are plain files.** Everything is markdown on your own disk, no accounts, no cloud, no lock-in. Back it up, sync it, grep it, own it.
|
package/package.json
CHANGED
|
@@ -99,17 +99,34 @@ function mergeSegments(segments) {
|
|
|
99
99
|
return merged;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
//
|
|
102
|
+
// Subset para auto-detección cuando el fence no declara lenguaje. Se excluyen
|
|
103
|
+
// lenguajes "genéricos" (css, markdown, ini, diff, toml): sobre texto plano
|
|
104
|
+
// producen demasiados falsos positivos.
|
|
105
|
+
const AUTO_SUBSET = [
|
|
106
|
+
'javascript', 'typescript', 'python', 'json', 'xml', 'bash', 'sql',
|
|
107
|
+
'java', 'go', 'rust', 'c', 'cpp', 'csharp', 'yaml', 'php', 'ruby'
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
// Umbral mínimo de relevancia para confiar en la auto-detección: el código
|
|
111
|
+
// real puntúa 3+, el texto plano se queda en 0-2.
|
|
112
|
+
const AUTO_MIN_RELEVANCE = 3;
|
|
113
|
+
|
|
114
|
+
// Devuelve segmentos coloreados del código. Con lenguaje declarado se respeta;
|
|
115
|
+
// sin lenguaje se intenta auto-detección; sin coincidencias fiables, texto plano.
|
|
103
116
|
export function highlightSegments(code, info) {
|
|
104
117
|
const language = String(info ?? '').trim().split(/\s+/)[0]?.toLowerCase() ?? '';
|
|
105
|
-
if (!language || !hljs.getLanguage(language)) {
|
|
106
|
-
return [{ text: code, color: null }];
|
|
107
|
-
}
|
|
108
118
|
try {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
if (language && hljs.getLanguage(language)) {
|
|
120
|
+
return mergeSegments(parseHljsHtml(hljs.highlight(code, { language, ignoreIllegals: true }).value));
|
|
121
|
+
}
|
|
122
|
+
if (!language) {
|
|
123
|
+
const result = hljs.highlightAuto(code, AUTO_SUBSET);
|
|
124
|
+
if (result.language && result.relevance >= AUTO_MIN_RELEVANCE) {
|
|
125
|
+
return mergeSegments(parseHljsHtml(result.value));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} catch {}
|
|
129
|
+
return [{ text: code, color: null }];
|
|
113
130
|
}
|
|
114
131
|
|
|
115
132
|
// Parte segmentos en líneas conservando el color de cada tramo.
|