Skip to content

Commit

Permalink
v1.2.0-alpha.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bogosorter committed Nov 1, 2024
1 parent 105598c commit 200d13a
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 144 deletions.
32 changes: 20 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "A simple markdown editor",
"version": "1.2.0-alpha.0",
"version": "1.2.0-alpha.1",
"keywords": [
"markdown",
"editor"
Expand Down Expand Up @@ -236,7 +236,11 @@
"output": "release/build"
},
"extraResources": [
"./assets/**"
"./assets/**",
{
"from": "node_modules/highlight.js",
"to": "node_modules/highlight.js"
}
],
"publish": {
"provider": "github",
Expand Down
4 changes: 2 additions & 2 deletions release/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elementary",
"version": "1.2.0-alpha.0",
"version": "1.2.0-alpha.1",
"description": "A simple markdown editor",
"license": "MIT",
"author": {
Expand Down
3 changes: 0 additions & 3 deletions roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ The following features are ordered according to their importance and ease of imp

- Review code highlight themes in preview
- Fix syntax highlight in embedded html
- Add upper/lower case shortcuts a
- Add line duplicate shortcut
- Add bold filename on open recent

## Long term

Expand Down
10 changes: 9 additions & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ ipcMain.handle('exportToPDF', async (_, mdPath: string) => {
const pdf = await mdToPdf({ path: mdPath }, {
document_title: 'Elementary',
css: exportCSS,
stylesheet: [],
pdf_options: {
printBackground: true,
margin: {
Expand All @@ -194,13 +195,17 @@ ipcMain.handle('exportToPDF', async (_, mdPath: string) => {
}
},
body_class: ['elementary'],
marked_extensions: [markedFootnote({ description: '' })]
marked_extensions: [markedFootnote({ description: '' })],
launch_options: {
args: ['--no-sandbox', '--disable-setuid-sandbox']
}
});
if (!pdf) return 1;

fs.writeFileSync(pdfPath, pdf.content);
return pdfPath;
} catch (e) {
console.log(e);
return 1;
}
});
Expand Down Expand Up @@ -233,3 +238,6 @@ ipcMain.handle('getVersionInfo', async () => {

return { firstTime, update };
});

// @ts-ignore
console.log(eval("require.resolve('highlight.js')"));
2 changes: 0 additions & 2 deletions src/renderer/texts/info.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ I loved Typora's editing experience, but it has since become a paid app... On th

Then, I learnt that VS Code's core editor, Monaco, was open-source. That's when the idea of adapting Monaco to fit my needs came to be. The core of Elementary is based on Monaco and should provide a reliable and bug-free experience. I did, however, change all of the editor's styles for aesthetic's sake, and built the logic that makes this a standalone app. Elementary uses electron and react, put together by the electron-react-boilerplate.

I plan to have an integrated PDF exporter soon and would like to implement a spell-checker as soon as possible.

I hope you enjoy Elementary!

bogosorter
Expand Down
81 changes: 34 additions & 47 deletions src/renderer/texts/pdfExportGuide.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,60 @@
# PDF export guide

- [Export configuration](#export-configuration)
- [Document title](#document-title)
- [PDF options](#pdf-options)
- [Custom header and footer](#custom-header-and-footer)
- [Including CSS](#including-css)
- [Additional tips](#additional-tips)
- [Export errors](#export-errors)





## Export configuration

Elementary's PDF exporter will work out of the box, but you'll likely want to configure it a little further. PDF configuration is done through some metadata at the top of the document in [YAML](https://en.wikipedia.org/wiki/YAML).
Please note that Elementary's PDF exporter will work out of the box. All of the steps described here are optional. PDF configuration is done through some metadata at the top of the document in [YAML](https://en.wikipedia.org/wiki/YAML).

To start a YAML block, insert this at the top of your document:

```txt
```markdown
---
# Content goes here
---
```

These are the available options:

### Document title

```yaml
---
document_title: The Complete History of Bogosort
---
```

document_title: Title

# There are four ways to add CSS to the document:
# - Inline CSS in the initial YAML (will only be rendered on exporting)
# - CSS files in initial YAML (will only be rendered on exporting)
# - Inline CSS using the <style> tag (see below)
# - CSS files included using the <link> tag (see below)

# Inline CSS in the initial YAML
css: "
# Some CSS variables defined for Elementary's theme that you might like to
# change
:root {
--font-size: 12px !important;
--text-align: justify !important;
--primary: "#3c3c3c" !important; # color used in text
--accent: "#286c93" !important; # colors used in headings, links, etc.
}

# Other CSS is also valid
p {
font-style: italic;
}
"
# CSS files in initial YAML
# Please make sure to use the **absolute** path
stylesheet:
- /home/bogosorter/styles.css
- etc.
### PDF options

# These classes are added to the <body> tag of the generated html and are useful
# to define various themes. By the default the `elementary` theme is used.
body_class:
- elementary
You may change the output file's dimensions, margins, and orientation.

```yaml
pdf_options:
landscape: true
format: A6
margin:
top: 10mm # px, mm, cm and in are all alowed
bottom: 10mm
left: 10mm
right: 10mm
```
# You can customize a header and a footer for your exported pdf using html.
# Some special variables are provided: `date`, `title`, `pageNumber`, and
# `totalPages`.
### Custom header and footer
You can customize a header and a footer for your exported pdf using html. Some special variables are provided: `date`, `title`, `pageNumber`, and `totalPages`. To use the `pageNumber`, for instance, you should have an element with the classname `pageNumber`. This might be a bit confusing - take a look at the examples:

```yaml
---
pdf_options:
displayHeaderFooter: true
headerTemplate: "
<p style='font-size: 14px; text-align: center; width: 100%; font-weight: bold'>
Expand All @@ -83,17 +66,22 @@ pdf_options:
<span class='pageNumber'></span>/<span class='totalPages'></span>
</p>
"
---
```

## Including CSS

Markdown's simplicity is quite useful for text editing, but it becomes somewhat limited when you want to apply custom styles to your document. That's why markdown supports inline html and allows you to include CSS styles.

You can embed CSS either into the initial metadata, as shown above, or into the body of your markdown file. Please note, though, that CSS included into the body will be rendered int both preview mode and the exported PDF, whereas CSS included in the YAML section will only be rendered in the exported PDF.
You can embed CSS either into the initial metadata or into the body of your markdown file. Please note, though, that CSS included into the body will be rendered in both preview mode and the exported PDF, whereas CSS included in the YAML section will only be rendered in the exported PDF.

Including CSS files in the YAML:

```yaml
stylesheet:
- /home/bogosorter/styles.css
- etc.
```

You can link to a CSS file in the body of your document:

Expand All @@ -112,7 +100,6 @@ Alternatively, you can include inline CSS like this:
```



## Additional tips

**Page Breaks**
Expand All @@ -136,4 +123,4 @@ The intermediate conversion into HTML is done using [Marked](https://marked.js.o

## Export errors

If Elementary reports an error while exporting, please check your export configuration carefully - that's where most errors come from. If the error persists please [file an issue](https://github.com/bogosorter/elementary/issues).
If Elementary reports an error while exporting, please check your export configuration carefully - that's where most errors come from. If the error persists please [file an issue](https://github.com/bogosorter/elementary/issues).
Loading

0 comments on commit 200d13a

Please sign in to comment.