1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
//! Helper functions dealing with HTML conversion.

use crate::config::LocalLinkKind;
use crate::markup_language::MarkupLanguage;
use parking_lot::RwLock;
use parse_hyperlinks::parser::Link;
use parse_hyperlinks_extras::iterator_html::HyperlinkInlineImage;
use parse_hyperlinks_extras::parser::parse_html::take_link;
use percent_encoding::{percent_decode_str, utf8_percent_encode, NON_ALPHANUMERIC};
use std::{
    collections::HashSet,
    path::{Component, Path, PathBuf},
    sync::Arc,
};

pub(crate) const HTML_EXT: &str = ".html";

/// If `rewrite_rel_links` and `dest` is relative, concat `docdir`  and
/// `dest`, then strip `root_path` from the left before returning.
/// If not `rewrite_rel_links` and `dest` is relative, return `dest`.
/// If `rewrite_abs_links` and `dest` is absolute, concatenate and return
/// `root_path` and `dest`.
/// If not `rewrite_abs_links` and `dest` is absolute, return `dest`.
/// The `dest` portion of the output is always canonicalized.
/// Return the assembled path, when in `root_path`, or `None` otherwise.
/// Asserts in debug mode, that `doc_dir` is in `root_path`.
fn assemble_link(
    root_path: &Path,
    docdir: &Path,
    dest: &Path,
    rewrite_rel_links: bool,
    rewrite_abs_links: bool,
) -> Option<PathBuf> {
    ///
    /// Concatenate `path` and `append`.
    /// The `append` portion of the output is if possible canonicalized.
    /// In case of underflow of an absolute link, the returned path is empty.
    fn append(path: &mut PathBuf, append: &Path) {
        // Append `dest` to `link` and canonicalize.
        for dir in append.components() {
            match dir {
                Component::ParentDir => {
                    if !path.pop() {
                        let path_is_relative = {
                            let mut c = path.components();
                            !(c.next() == Some(Component::RootDir)
                                || c.next() == Some(Component::RootDir))
                        };
                        if path_is_relative {
                            path.push(Component::ParentDir.as_os_str());
                        } else {
                            path.clear();
                            break;
                        }
                    }
                }
                Component::Normal(c) => path.push(c),
                _ => {}
            }
        }
    }

    // Under Windows `.is_relative()` does not detect `Component::RootDir`
    let dest_is_relative = {
        let mut c = dest.components();
        !(c.next() == Some(Component::RootDir) || c.next() == Some(Component::RootDir))
    };

    // Check if the link points into `root_path`, reject otherwise
    // (strip_prefix will not work).
    debug_assert!(docdir.starts_with(root_path));

    // Caculate the output.
    let mut link = match (rewrite_rel_links, rewrite_abs_links, dest_is_relative) {
        // *** Relative links.
        // Result: "/" + docdir.strip(root_path) + dest
        (true, false, true) => {
            let link = PathBuf::from(Component::RootDir.as_os_str());
            link.join(docdir.strip_prefix(root_path).ok()?)
        }
        // Result: docdir + dest
        (true, true, true) => docdir.to_path_buf(),
        // Result: dest
        (false, _, true) => PathBuf::new(),
        // *** Absolute links.
        // Result: "/" + dest
        (_, false, false) => PathBuf::from(Component::RootDir.as_os_str()),
        // Result: "/" + root_path
        (_, true, false) => root_path.to_path_buf(),
    };
    append(&mut link, dest);

    if link.as_os_str().is_empty() {
        None
    } else {
        Some(link)
    }
}

#[inline]
/// Helper function that converts relative local HTML links to absolute
/// links. If successful, we return `Some(converted_anchor_tag, target)`.
///
/// The base path for this conversion (usually where the HTML file resides),
/// is `docdir`.
/// If not `rewrite_rel_links`, relative local links are not converted.
/// Furthermore, all local _absolute_ (not converted) links are prepended with
/// `root_path`. All external URLs always remain untouched.
/// If `rewrite_abs_links` and `link` is absolute, concatenate and return
/// `root_path` and `dest`.
/// If not `rewrite_abs_links` and dest` is absolute, return `dest`.
/// If `rewrite_ext` is true and the link points to a known Tp-Note file
/// extension, then `.html` is appended to the converted link.
/// Remark: The _anchor's text property_ is never changed. However, there is
/// one exception: when the text contains a URL starting with `http:` or
/// `https:`, only the file stem is kept. Example, the anchor text property:
/// `<a ...>http:dir/my file.md</a>` is rewritten into `<a ...>my file</a>`.
///
/// Contract 1: `link` must be local. It may have a scheme.
/// Contract 2: `root_path` and `docdir` are absolute paths to directories.
/// Contract 3: `root_path` is never empty `""`. It can be `"/"`.
/// Contract 4: The returned link is guaranteed to be a child of `root_path`, or
/// `None`.

fn rewrite_link(
    link: &str,
    root_path: &Path,
    docdir: &Path,
    rewrite_rel_links: bool,
    rewrite_abs_links: bool,
    rewrite_ext: bool,
) -> Option<(String, PathBuf)> {
    //
    const ASCIISET: percent_encoding::AsciiSet = NON_ALPHANUMERIC
        .remove(b'/')
        .remove(b'.')
        .remove(b'_')
        .remove(b'-');

    match take_link(link) {
        Ok(("", ("", Link::Text2Dest(text, dest, title)))) => {
            // Check contract 1. Panic if link is not local.
            debug_assert!(!link.contains("://"));

            // Only rewrite file extensions for Tp-Note files.
            let rewrite_ext = rewrite_ext
                && !matches!(
                    MarkupLanguage::from(Path::new(&*dest)),
                    MarkupLanguage::None
                );

            // Local ones are Ok. Trim URL scheme.
            let dest = dest
                .trim_start_matches("http:")
                .trim_start_matches("https:");

            let mut short_text = text.to_string();

            // Example: display `my text` for the local relative URL: `<http:my%20text.md>`.
            if text.starts_with("http:") || text.starts_with("https:") {
                // Improves pretty printing:
                let text = text
                    .trim_start_matches("http:")
                    .trim_start_matches("https:");
                let text = PathBuf::from(&*percent_decode_str(text).decode_utf8().unwrap());
                let text = text
                    .file_stem()
                    .unwrap_or_default()
                    .to_str()
                    .unwrap_or_default();
                short_text = text.to_string();
            }

            // Append ".html" if `rewrite_ext`.
            let dest = &*percent_decode_str(dest).decode_utf8().unwrap();
            let dest = if rewrite_ext {
                let mut dest = dest.to_string();
                dest.push_str(HTML_EXT);
                PathBuf::from(dest)
            } else {
                PathBuf::from(dest)
            };

            let destout = assemble_link(
                root_path,
                docdir,
                &dest,
                rewrite_rel_links,
                rewrite_abs_links,
            )?;

            // Convert to str.
            let destout_encoded = destout.to_str().unwrap_or_default();
            // Windows: replace `\` with `/`.
            #[cfg(windows)]
            let destout_encoded = destout_encoded
                .chars()
                .map(|c| if c == '\\' { '/' } else { c })
                .collect::<String>();
            #[cfg(windows)]
            let destout_encoded = destout_encoded.as_str();
            let destout_encoded = utf8_percent_encode(destout_encoded, &ASCIISET).to_string();
            Some((
                format!(
                    "<a href=\"{}\" title=\"{}\">{}</a>",
                    destout_encoded, title, short_text
                ),
                destout,
            ))
        }

        Ok(("", ("", Link::Image(text, dest)))) => {
            // Concat `abspath` and `relpath`.
            let dest = PathBuf::from(&*percent_decode_str(&dest).decode_utf8().unwrap());

            let destout = assemble_link(
                root_path,
                docdir,
                &dest,
                rewrite_rel_links,
                rewrite_abs_links,
            )?;

            // Convert to str.
            let destout_encoded = destout.to_str().unwrap_or_default();
            // Windows: replace `\` with `/`.
            //#[cfg(windows)]
            let destout_encoded = destout_encoded
                .chars()
                .map(|c| if c == '\\' { '/' } else { c })
                .collect::<String>();
            //#[cfg(windows)]
            let destout_encoded = destout_encoded.as_str();
            let destout_encoded = utf8_percent_encode(destout_encoded, &ASCIISET).to_string();
            Some((
                format!("<img src=\"{}\" alt=\"{}\" />", destout_encoded, text),
                destout,
            ))
        }

        Ok((_, (_, _))) | Err(_) => None,
    }
}

#[inline]
/// Helper function that scans the input `html` string and converts
/// all relative local HTML links to absolute links.
///
/// The base path for this conversion (usually where the HTML file resides),
/// is `docdir`.
/// If not `rewrite_rel_links`, relative local links are not converted.
/// Furthermore, all local _absolute_ (not converted) links are prepended with
/// `root_path`. All external URLs always remain untouched.
/// If `rewrite_abs_links` and `link` is absolute, concatenate and return
/// `root_path` and `dest`.
/// If `rewrite_ext` is true and the link points to a known Tp-Note file
/// extension, then `.html` is appended to the converted link.
/// Remark: The _anchor's text property_ is never changed. However, there is
/// one exception: when the text contains a URL starting with `http:` or
/// `https:`, only the file stem is kept. Example, the anchor text property:
/// `<a ...>http:dir/my file.md</a>` is rewritten into `<a ...>my file</a>`.
///
/// It is guaranteed, that all local links in the converted `html` point inside
/// `root_path`. If not, the link is displayed as `INVALID LOCAL LINK` and
/// discarded. All valid local links are inserted in `allowed_local_links`
/// the same way as their destination appears in the resulting HTML.
pub fn rewrite_links(
    html: String,
    root_path: &Path,
    docdir: &Path,
    local_link_kind: LocalLinkKind,
    rewrite_ext: bool,
    allowed_local_links: Arc<RwLock<HashSet<PathBuf>>>,
) -> String {
    let (rewrite_rel_links, rewrite_abs_links) = match local_link_kind {
        LocalLinkKind::Off => (false, false),
        LocalLinkKind::Short => (true, false),
        LocalLinkKind::Long => (true, true),
    };

    let mut allowed_urls = allowed_local_links.write();

    // Search for hyperlinks and inline images in the HTML rendition
    // of this note.
    let mut rest = &*html;
    let mut html_out = String::new();
    for ((skipped, consumed, remaining), link) in HyperlinkInlineImage::new(&html) {
        html_out.push_str(skipped);
        rest = remaining;

        // We skip absolute URLs, `mailto:` and `tel:` links.
        if link.contains("://") || link.starts_with("mailto:") || link.starts_with("tel:") {
            html_out.push_str(consumed);
            continue;
        }

        // Rewrite the link.
        if let Some((consumed_new, dest)) = rewrite_link(
            consumed,
            root_path,
            docdir,
            rewrite_rel_links,
            rewrite_abs_links,
            rewrite_ext,
        ) {
            html_out.push_str(&consumed_new);
            allowed_urls.insert(dest);
        } else {
            log::debug!("Viewer: invalid_local_links: {}", consumed);
            html_out.push_str("<i>INVALID LOCAL LINK</i>");
        }
    }
    // Add the last `remaining`.
    html_out.push_str(rest);

    if allowed_urls.is_empty() {
        log::debug!(
            "Viewer: note file has no local hyperlinks. No additional local files are served.",
        );
    } else {
        log::debug!(
            "Viewer: referenced allowed local files: {}",
            allowed_urls
                .iter()
                .map(|p| {
                    let mut s = "\n    '".to_string();
                    s.push_str(&p.display().to_string());
                    s
                })
                .collect::<String>()
        );
    }

    html_out
    // The `RwLockWriteGuard` is released here.
}

#[cfg(test)]
mod tests {

    use parking_lot::RwLock;
    use std::{
        collections::HashSet,
        path::{Path, PathBuf},
        sync::Arc,
    };

    use crate::html::assemble_link;
    use crate::html::rewrite_link;
    use crate::html::rewrite_links;

    #[test]
    fn test_assemble_link() {
        // `rewrite_rel_links=true`
        let output = assemble_link(
            Path::new("/my"),
            Path::new("/my/doc/path"),
            Path::new("../local/link to/note.md"),
            true,
            false,
        )
        .unwrap();
        assert_eq!(output, Path::new("/doc/local/link to/note.md"));

        // `rewrite_rel_links=false`
        let output = assemble_link(
            Path::new("/my"),
            Path::new("/my/doc/path"),
            Path::new("../local/link to/note.md"),
            false,
            false,
        )
        .unwrap();
        assert_eq!(output, Path::new("../local/link to/note.md"));

        // Absolute `dest`.
        let output = assemble_link(
            Path::new("/my"),
            Path::new("/my/doc/path"),
            Path::new("/test/../abs/local/link to/note.md"),
            false,
            false,
        )
        .unwrap();
        assert_eq!(output, Path::new("/abs/local/link to/note.md"));

        // Underflow.
        let output = assemble_link(
            Path::new("/my"),
            Path::new("/my/doc/path"),
            Path::new("/../local/link to/note.md"),
            false,
            false,
        );
        assert_eq!(output, None);

        // Absolute `dest`, `rewrite_abs_links=true`.
        let output = assemble_link(
            Path::new("/my"),
            Path::new("/my/doc/path"),
            Path::new("/abs/local/link to/note.md"),
            false,
            true,
        )
        .unwrap();
        assert_eq!(output, Path::new("/my/abs/local/link to/note.md"));

        // Absolute `dest`, `rewrite_abs_links=false`.
        let output = assemble_link(
            Path::new("/my"),
            Path::new("/my/doc/path"),
            Path::new("/test/../abs/local/link to/note.md"),
            false,
            false,
        )
        .unwrap();
        assert_eq!(output, Path::new("/abs/local/link to/note.md"));

        // Absolute `dest`, `rewrite` both.
        let output = assemble_link(
            Path::new("/my"),
            Path::new("/my/doc/path"),
            Path::new("abs/local/link to/note.md"),
            true,
            true,
        )
        .unwrap();
        assert_eq!(output, Path::new("/my/doc/path/abs/local/link to/note.md"));
    }

    #[test]
    #[should_panic(expected = "assertion failed: !link.contains(\\\"://\\\")")]
    fn test_rewrite_link1() {
        let root_path = Path::new("/my/");
        let docdir = Path::new("/my/abs/note path/");

        // Should panic: this is not a relative path.
        let input = "<a href=\"ftp://getreu.net\">Blog</a>";
        let _ = rewrite_link(input, root_path, docdir, true, false, false).unwrap();
    }

    #[test]
    fn test_rewrite_link2() {
        let root_path = Path::new("/my/");
        let docdir = Path::new("/my/abs/note path/");

        // Check relative path to image.
        let input = "<img src=\"down/./down/../../t%20m%20p.jpg\" alt=\"Image\" />";
        let expected = "<img src=\"/abs/note%20path/t%20m%20p.jpg\" \
            alt=\"Image\" />";
        let (outhtml, outpath) =
            rewrite_link(input, root_path, docdir, true, false, false).unwrap();

        assert_eq!(outhtml, expected);
        assert_eq!(outpath, PathBuf::from("/abs/note path/t m p.jpg"));

        // Check relative path to image. Canonicalized?
        let input = "<img src=\"down/./../../t%20m%20p.jpg\" alt=\"Image\" />";
        let expected = "<img src=\"../t%20m%20p.jpg\" alt=\"Image\" />";
        let (outhtml, outpath) =
            rewrite_link(input, root_path, docdir, false, false, false).unwrap();

        assert_eq!(outhtml, expected);
        assert_eq!(outpath, PathBuf::from("../t m p.jpg"));

        // Check relative path to note file.
        let input = "<a href=\"./down/./../my%20note%201.md\">my note 1</a>";
        let expected = "<a href=\"/abs/note%20path/my%20note%201.md\" \
            title=\"\">my note 1</a>";
        let (outhtml, outpath) =
            rewrite_link(input, root_path, docdir, true, false, false).unwrap();

        assert_eq!(outhtml, expected);
        assert_eq!(outpath, PathBuf::from("/abs/note path/my note 1.md"));

        // Check absolute path to note file.
        let input = "<a href=\"/dir/./down/../my%20note%201.md\">my note 1</a>";
        let expected = "<a href=\"/dir/my%20note%201.md\" \
            title=\"\">my note 1</a>";
        let (outhtml, outpath) =
            rewrite_link(input, root_path, docdir, true, false, false).unwrap();

        assert_eq!(outhtml, expected);
        assert_eq!(outpath, PathBuf::from("/dir/my note 1.md"));

        // Check relative path to note file. Canonicalized?
        let input = "<a href=\"./down/./../dir/my%20note%201.md\">my note 1</a>";
        let expected = "<a href=\"dir/my%20note%201.md\" \
            title=\"\">my note 1</a>";
        let (outhtml, outpath) =
            rewrite_link(input, root_path, docdir, false, false, false).unwrap();

        assert_eq!(outhtml, expected);
        assert_eq!(outpath, PathBuf::from("dir/my note 1.md"));

        // Check `rewrite_ext=true`.
        let input = "<a href=\"./down/./../dir/my%20note%201.md\">my note 1</a>";
        let expected = "<a href=\"/abs/note%20path/dir/my%20note%201.md.html\" \
            title=\"\">my note 1</a>";
        let (outhtml, outpath) = rewrite_link(input, root_path, docdir, true, false, true).unwrap();

        assert_eq!(outhtml, expected);
        assert_eq!(
            outpath,
            PathBuf::from("/abs/note path/dir/my note 1.md.html")
        );

        // Check relative link in input.
        let input = "<a href=\"./down/./../dir/my%20note%201.md\">my note 1</a>";
        let expected = "<a href=\"/path/dir/my%20note%201.md\" title=\"\">my note 1</a>";
        let (outhtml, outpath) = rewrite_link(
            input,
            Path::new("/my/note/"),
            Path::new("/my/note/path/"),
            true,
            false,
            false,
        )
        .unwrap();

        assert_eq!(outhtml, expected);
        assert_eq!(outpath, PathBuf::from("/path/dir/my note 1.md"));

        // Check absolute link in input.
        let input = "<a href=\"/down/./../dir/my%20note%201.md\">my note 1</a>";
        let expected = "<a href=\"/dir/my%20note%201.md\" title=\"\">my note 1</a>";
        let (outhtml, outpath) = rewrite_link(
            input,
            root_path,
            Path::new("/my/ignored/"),
            true,
            false,
            false,
        )
        .unwrap();

        assert_eq!(outhtml, expected);
        assert_eq!(outpath, PathBuf::from("/dir/my note 1.md"));

        // Check absolute link in input, not in `root_path`.
        let input = "<a href=\"/down/../../dir/my%20note%201.md\">my note 1</a>";
        let output = rewrite_link(
            input,
            root_path,
            Path::new("/my/notepath/"),
            true,
            false,
            false,
        );

        assert_eq!(output, None);

        // Check relative link in input, not in `root_path`.
        let input = "<a href=\"../../dir/my%20note%201.md\">my note 1</a>";
        let output = rewrite_link(
            input,
            root_path,
            Path::new("/my/notepath/"),
            true,
            false,
            false,
        );

        assert_eq!(output, None);

        // Check relative link in input, with underflow.
        let root_path = Path::new("/");
        let input = "<a href=\"../../dir/my%20note%201.md\">my note 1</a>";
        let output = rewrite_link(input, root_path, Path::new("/my/"), true, false, false);

        assert_eq!(output, None);

        // Check relative link in input, not in `root_path`.
        let root_path = Path::new("/my");
        let input = "<a href=\"../../dir/my%20note%201.md\">my note 1</a>";
        let output = rewrite_link(
            input,
            root_path,
            Path::new("/my/notepath"),
            true,
            false,
            false,
        );

        assert_eq!(output, None);
    }

    #[test]
    fn test_rewrite_abs_links() {
        use crate::config::LocalLinkKind;

        let allowed_urls = Arc::new(RwLock::new(HashSet::new()));
        let input = "abc<a href=\"ftp://getreu.net\">Blog</a>\
            def<a href=\"https://getreu.net\">https://getreu.net</a>\
            ghi<img src=\"t%20m%20p.jpg\" alt=\"test 1\" />\
            jkl<a href=\"down/../down/my%20note%201.md\">my note 1</a>\
            mno<a href=\"http:./down/../dir/my%20note.md\">\
            http:./down/../dir/my%20note.md</a>\
            pqr<a href=\"http:/down/../dir/my%20note.md\">\
            http:./down/../dir/my%20note.md</a>\
            stu<a href=\"http:/../dir/underflow/my%20note.md\">\
            not allowed dir</a>\
            vwx<a href=\"http:../../../not allowed dir/my%20note.md\">\
            not allowed</a>"
            .to_string();
        let expected = "abc<a href=\"ftp://getreu.net\">Blog</a>\
            def<a href=\"https://getreu.net\">https://getreu.net</a>\
            ghi<img src=\"/abs/note%20path/t%20m%20p.jpg\" alt=\"test 1\" />\
            jkl<a href=\"/abs/note%20path/down/my%20note%201.md\" title=\"\">my note 1</a>\
            mno<a href=\"/abs/note%20path/dir/my%20note.md\" title=\"\">my note</a>\
            pqr<a href=\"/dir/my%20note.md\" title=\"\">my note</a>\
            stu<i>INVALID LOCAL LINK</i>\
            vwx<i>INVALID LOCAL LINK</i>"
            .to_string();

        let root_path = Path::new("/my/");
        let docdir = Path::new("/my/abs/note path/");
        let output = rewrite_links(
            input,
            root_path,
            docdir,
            LocalLinkKind::Short,
            false,
            allowed_urls.clone(),
        );
        let url = allowed_urls.read_recursive();

        assert_eq!(output, expected);
        assert!(url.contains(&PathBuf::from("/abs/note path/t m p.jpg")));
        assert!(url.contains(&PathBuf::from("/abs/note path/dir/my note.md")));
        assert!(url.contains(&PathBuf::from("/abs/note path/down/my note 1.md")));
    }
}