Skip to content

Add support for extension settings passed to markdown-it-pandoc #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ try
build
public/katex/
public/paged.polyfill.js
public/highlight.js
9 changes: 7 additions & 2 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ If the directory does not exist, you can create it.

## Settings

If you put a `settings.yaml` file in the data directory, PanWriter will read it on startup. Possible fields are currently only:
If you put a `settings.yaml` file in the data directory, PanWriter will read it on startup. Available settings are:

autoUpdateApp: true
autoUpdateApp: true # whether to automatically check for and install updates
extensions: # optional: configure markdown-it extensions
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
extensions: # optional: configure markdown-it extensions
extensions: # optional: configure markdown-it-pandoc extensions

some-extension: true
other-extension: false

For available extension options and their effects, please refer to the [markdown-it-pandoc documentation](https://github.com/mb21/markdown-it-pandoc#readme).

## Default CSS and YAML

Expand Down
4 changes: 4 additions & 0 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ const createWindow = async (filePath?: string, toImport=false, wasCreatedOnStart
} else {
ipc.sendMessage(win, { type: 'loadSettings', settings })
}
} else {
const settings = await settingsPromise
await windowReady
ipc.sendMessage(win, { type: 'loadSettings', settings })
}
await windowReady
ipc.sendPlatform(win)
Expand Down
7 changes: 5 additions & 2 deletions electron/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ export const loadSettings = async (): Promise<Settings> => {
}

const parseSettings = (data: Record<string, unknown> = {}): Settings => {
const { autoUpdateApp } = data
const { autoUpdateApp, extensions } = data
return {
autoUpdateApp: autoUpdateApp === undefined ? defaultSettings.autoUpdateApp : !!autoUpdateApp
autoUpdateApp: autoUpdateApp === undefined ? defaultSettings.autoUpdateApp : !!autoUpdateApp,
extensions: typeof extensions === 'object' && extensions !== null
? extensions as Record<string, boolean>
: defaultSettings.extensions
}
}
Loading