zhuochun / md-writer

✒️ Make Atom a better Markdown/AsciiDoc editor for writers and bloggers
https://atom.io/packages/markdown-writer
MIT License
341 stars 46 forks source link

{slug} does not replace space with slugSeparator used with siteImagesDir #312

Closed fkjensen closed 2 years ago

fkjensen commented 2 years ago

Describe the bug {slug} does not replace space with slugSeparator used with siteImagesDir.

I created a project specific _mdwriter.cson configuration with a minimal setup where I would like the markdown filename to be used with the {slug} counterpart. I expected that the filename "test space.md" would have a corresponding {slug} as "testspace.md" with slugSeparator is set to "".

Mac OS X: 12.3 Atom: 1.60.0

To Reproduce Steps to reproduce the behavior:

  1. First I do a new project "wr" by making a directory named "t/wr". In that directory I use Atom to create a new "_mdwriter.cson" project specific configuration file with the following configuration

    siteEngine: "general"
    fileExtension: ".md"
    slugSeparator: "_"
    siteLocalDir: ""
    siteImagesDir: "assets/{slug}/"
    imageTag: "![{alt}]({relativeSiteSrc})"
    relativeImagePath: true
  2. On Mac OS X based Atom I do a "Cmd-Shift-3" to copy a screenshot and then do a "Cmd-Shift-I" to copy the screenshot into a project specific folder configured.

  3. With a filename "testnospace.md" I happen to get the following link and a file in assets/testnospace/a.png as intended and expected

    # Test No Space In Filename
    ![a](assets/testnospace/a.png)
  4. With a filename "test space.md" I happen to get the follwing link and a file in "assets/test space/a.png" which is not what I intended or expected. I know that I expect {slug} to be computed from the filename.

    test one:
    ![a](assets/test space/a.png)
  5. I tried to set the slug manually by adding the slug defintion to frontmatter:

    
    ---
    slug: test_space
    ---
    test one:
    ![a](assets/test space/a.png)

test two with manual slug in frontmatter: ![b](assets/test space/b.png)


**Expected behavior**
I expected the following content after doing the clipboard screenshot and a paste of the clipboard to Atom. {slug} with filename spaces replaced by slugSeparator is expected. Am I missing something here or is it a bug?

test one: c

zhuochun commented 2 years ago

Currently, filename is assumed to be slug-ed and used directly to {slug} placeholder.

But agree, front matter slug should be respected.