Skip to content

Commit

Permalink
Preview markdown update 🐶
Browse files Browse the repository at this point in the history
- Replaced Preview's markdown.css with github-markdown-css by @sindresorhus
- Added IniGroup Preview
- Subclassed QWebEngineView and moved a few previously ill-parented objects to its constructor
- Reordered Set and Toggle menu sections (alphabetical by IniGroup: Data, Editor, Preview, Window)
  • Loading branch information
fairybow committed Feb 2, 2023
1 parent f05c271 commit 1f2e0b6
Show file tree
Hide file tree
Showing 25 changed files with 3,198 additions and 286 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ Solarized theme palettes by [@altercation](https://github.com/altercation/solari

[Markdown](https://www.markdownguide.org/)/[Fountain](https://fountain.io/) preview support provided with:
- [Marked.js](https://github.com/markedjs/marked)
- [Markdown.css](https://bitbucket.org/kevinburke/markdowncss)
- and [Fountain.js](https://github.com/mattdaly/Fountain.js)
- github-markdown-css by [@sindresorhus](https://github.com/sindresorhus/github-markdown-css)
- and Fountain.js by [@mattdaly](https://github.com/mattdaly/Fountain.js)

> **Note:** Markdown/Fountain support is, at the moment, extremely barebones!
Expand Down
3 changes: 1 addition & 2 deletions fernanda/docs/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,9 @@
#include <QEvent>
#include <QObject>
#include <Qt>
#include <QUrl>
#include <QWebChannel>
#include <QWebEnginePage>
//#include <QWebEngineProfile>
//#include <QWebEngineScriptCollection>
#include <QWebEngineView>
#include <QWidget>
Expand Down
9 changes: 9 additions & 0 deletions fernanda/docs/github-markdown-css/license
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
63 changes: 63 additions & 0 deletions fernanda/docs/github-markdown-css/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# github-markdown-css

> The minimal amount of CSS to replicate the GitHub Markdown style
**The CSS is generated. Contributions should go to [this repo](https://github.com/sindresorhus/generate-github-markdown-css).**

[<img src="https://cloud.githubusercontent.com/assets/170270/5219062/f22a978c-7685-11e4-8316-af25b6c89bc0.png" width="300">](http://sindresorhus.com/github-markdown-css)

## [Demo](https://sindresorhus.com/github-markdown-css)

## Install

Download [manually](https://raw.githubusercontent.com/sindresorhus/github-markdown-css/gh-pages/github-markdown.css), from [CDNJS](https://cdnjs.com/libraries/github-markdown-css), or with npm:

```
$ npm install github-markdown-css
```

## Usage

Import the `github-markdown.css` file and add a `markdown-body` class to the container of your rendered Markdown and set a width for it. GitHub uses `980px` width and `45px` padding, and `15px` padding for mobile.

```html
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="github-markdown.css">
<style>
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}
@media (max-width: 767px) {
.markdown-body {
padding: 15px;
}
}
</style>
<article class="markdown-body">
<h1>Unicorns</h1>
<p>All the things</p>
</article>
```

If you want code syntax highlighted, use GitHub Flavored Markdown rendered from [GitHub's `/markdown` API](https://docs.github.com/en/free-pro-team@latest/rest/reference/markdown).

There are 3 themes provided in this package:

- **github-markdown.css**: (default) Automatically switches between light and dark through [`@media (prefers-color-scheme)`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme).
- **github-markdown-light.css**: Light-only.
- **github-markdown-dark.css**: Dark-only.

You may know that now GitHub supports more than 2 themes including `dark_dimmed`, `dark_high_contrast` and `colorblind` variants. If you want to try these themes, you can generate them on your own! See next section.

## How

See [`generate-github-markdown-css`](https://github.com/sindresorhus/generate-github-markdown-css) for how it's generated and ability to generate your own.

## Dev

Run `npm run make` to update the CSS.
3 changes: 0 additions & 3 deletions fernanda/docs/markdown.css/README.md

This file was deleted.

16 changes: 0 additions & 16 deletions fernanda/docs/markdown.css/license.txt

This file was deleted.

Binary file added fernanda/docs/zips/github-markdown-css-5.1.0.zip
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions fernanda/fernanda.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@
<None Include="..\README.md" />
<None Include="cpp.hint" />
<None Include="docs\palette.md" />
<None Include="res\preview\fountain-overwrite.css" />
<None Include="res\preview\fountain.html" />
<None Include="res\preview\markdown-overwrite.css" />
<None Include="res\preview\markdown.html" />
<None Include="res\sample\Sample.fernanda_editor" />
<None Include="res\sample\Sample.fernanda_window" />
Expand Down
6 changes: 6 additions & 0 deletions fernanda/fernanda.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@
<None Include="res\preview\fountain.html">
<Filter>Resource Files\Preview</Filter>
</None>
<None Include="res\preview\markdown-overwrite.css">
<Filter>Resource Files\Preview</Filter>
</None>
<None Include="res\preview\fountain-overwrite.css">
<Filter>Resource Files\Preview</Filter>
</None>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />
Expand Down
10 changes: 7 additions & 3 deletions fernanda/res/preview.qrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<RCC>
<qresource prefix="/">
<file>preview/fountain.html</file>
<file>preview/fountain-overwrite.css</file>
<file>preview/markdown.html</file>
<file>preview/markdown-overwrite.css</file>
<file>preview/include/fountain.min.js</file>
<file>preview/include/fountain-js.css</file>
<file>preview/include/markdown.css</file>
<file>preview/include/github-markdown.css</file>
<file>preview/include/github-markdown-dark.css</file>
<file>preview/include/github-markdown-light.css</file>
<file>preview/include/marked.min.js</file>
<file>preview/fountain.html</file>
<file>preview/markdown.html</file>
</qresource>
</RCC>
2 changes: 2 additions & 0 deletions fernanda/res/preview/fountain-overwrite.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
body {
}
45 changes: 23 additions & 22 deletions fernanda/res/preview/fountain.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
<!doctype html>
<meta charset="utf-8">
<html lang="en">
<head>
<link rel="stylesheet" href="include/fountain-js.css">
<script src="include/fountain.min.js"></script>
<script src="qrc:/qtwebchannel/qwebchannel.js"></script>
</head>
<body>
<div id="placeholder"></div>
<script>
'use strict';
var placeholder = document.getElementById('placeholder');
var updateText = function (text) {
var output = fountain.parse(text);
placeholder.innerHTML = output.html.title_page + output.html.script;
<head>
<link rel="stylesheet" href="include/fountain-js.css">
<link rel="stylesheet" href="fountain-overwrite.css">
<script src="include/fountain.min.js"></script>
<script src="qrc:/qtwebchannel/qwebchannel.js"></script>
</head>
<body>
<div id="text_area"></div>
<script>
'use strict';
var text_area = document.getElementById('text_area');
var updateText = function (text) {
var output = fountain.parse(text);
text_area.innerHTML = output.html.title_page + output.html.script;
}
new QWebChannel(qt.webChannelTransport,
function(channel) {
var content = channel.objects.content;
updateText(content.text);
content.textChanged.connect(updateText);
}
new QWebChannel(qt.webChannelTransport,
function(channel) {
var content = channel.objects.content;
updateText(content.text);
content.textChanged.connect(updateText);
}
);
</script>
</body>
);
</script>
</body>
</html>
Loading

0 comments on commit 1f2e0b6

Please sign in to comment.