mokeyish / obsidian-enhancing-export

This is an enhancing export plugin base on Pandoc for Obsidian (https://obsidian.md/ ). It's allow you to export to formats like Markdown、Markdown (Hugo https://gohugo.io/ )、Html、docx、Latex etc.
MIT License
301 stars 17 forks source link

Adding latex template support #66

Closed universvm closed 1 year ago

universvm commented 1 year ago

Hi there,

I use this plugin with templates like Eisvogel https://github.com/Wandmalfarbe/pandoc-latex-template/tree/master

I was thinking that some of these templates could be integrated as part of the plugin. What are your thoughts? I'm not sure how the user could interact with these in terms of UI. In terms of functionality I think we can modify the pandoc code.

Alternatively the user could specify their own templates and add them to a folder.

Let me know what you think

mokeyish commented 1 year ago

The list of optional templates can be configured in the settings interface. Then, in the export interface, if it is judged that there is a template list, it will drop down to let the user select a template.

mokeyish commented 1 year ago

I think the current ui code is too complicated and not easy to maintain. I want to switch to solidjs, but I don't have time to do it.

mokeyish commented 1 year ago

I've migrated UI code to solidjs #68

mokeyish commented 1 year ago

Now, it is more easy to understand than before.

图片

universvm commented 1 year ago

Hey there, thank you for this, you're awesome!

Small comment, I'd change "Edit Command Template" --> "Edit Pandoc Command". So that we can create a section called "Choose Latex Template". I can change it if you want :)

If you're good with it, I will spend some time creating some latex templates like:

  1. Academic Template (probably based off eisvogel)
  2. Academic Template 2-columns

Can you think of any others you think could be useful?

mokeyish commented 1 year ago
universvm commented 1 year ago
mokeyish commented 1 year ago

What's this meaning of From Wikipedia: The term template, when used in the context of word processing software, refers to a sample document that has already some details in place?

I don't understand.

It seems not all the export formats, eg: markdown.

universvm commented 1 year ago

This is an example of a PDF using Obsidian Enhancing Export and Latex Templates: https://miro.medium.com/v2/resize:fit:1400/format:webp/1*b3TJ4anKjyokTPCjOvp5Iw.png

See section 4: https://betterhumans.pub/obsidian-tutorial-for-academic-writing-87b038060522

We can automate this by having built in latex templates. I can help with this

mokeyish commented 1 year ago
mokeyish commented 1 year ago

Eg: update the tempate

https://github.com/mokeyish/obsidian-enhancing-export/blob/2a08bf2c4ec03d597472049b5db865a7a7c4a84e/src/export_command_templates.ts#L57-L64

to

{
    name: 'PDF',
    type: 'pandoc',
    arguments:
      '-f markdown --resource-path="${currentDir}" --resource-path="${attachmentFolderPath}" --lua-filter="${luaDir}/pdf.lua" --embed-resources --standalone --metadata title="${currentFileName}" -s -o "${outputPath}" -t pdf',
    customArguments: '--pdf-engine=typst',
    latexTemplates: [
       "latextemplateNameA": "latexTemplatePathA",
       "latextemplateNameB": "latexTemplatePathB",
   ],
    extension: '.pdf',
}
mokeyish commented 1 year ago

Then: 图片

mokeyish commented 1 year ago

Thank you very much if you can help implement this function. Feel free to ask me any questions about this.

universvm commented 1 year ago

Yeah I ideally wanted to keep a folder with some latex templates. We can either:

  1. Download them from an separate repository
  2. Add them as part of this repository (it may increase the size of the plugin though)

what do you think is better?

Thanks for the suggestions! I will try to implement the basic logic and send it to you for review sometime soon.

mokeyish commented 1 year ago

I think both are ok 😊. looking forward to your PR.

mokeyish commented 1 year ago

I've added CONTRIBUTING document.But my English is not good😂, and writing is relatively simple.

universvm commented 1 year ago

Thank you!

universvm commented 1 year ago

@mokeyish I am almost done with the code but I encounter this error after following your guide:

failed to load config from /Users/leo/Documents/code/obsidian-enhancing-export/vite.config.ts error during build: Error: ENOENT: no such file or directory, lstat 'dist'

Any chance you know what may be happening? I followed this guide: https://github.com/mokeyish/obsidian-enhancing-export/blob/main/CONTRIBUTING.md

Let me know if you're able to test. Also have a look at the current state of the changes: https://github.com/mokeyish/obsidian-enhancing-export/pull/80

mokeyish commented 1 year ago

@mokeyish I am almost done with the code but I encounter this error after following your guide:

failed to load config from /Users/leo/Documents/code/obsidian-enhancing-export/vite.config.ts error during build: Error: ENOENT: no such file or directory, lstat 'dist'

Any chance you know what may be happening? I followed this guide: https://github.com/mokeyish/obsidian-enhancing-export/blob/main/CONTRIBUTING.md

Let me know if you're able to test. Also have a look at the current state of the changes: #80

Please comment these lines temporary(I never develop on MACOS, it maybe some bug).

https://github.com/mokeyish/obsidian-enhancing-export/blob/8345d2485a8ff0ecede4a2804d6cdf7db1a72ac5/vite.config.ts#L27-L30