Skip to content
New issue

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

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

Already on GitHub? # to your account

Possibility to add own themes and to save the HTML #92

Open
mpathy opened this issue Mar 21, 2016 · 3 comments
Open

Possibility to add own themes and to save the HTML #92

mpathy opened this issue Mar 21, 2016 · 3 comments

Comments

@mpathy
Copy link

mpathy commented Mar 21, 2016

It would be great if there would be the possibility to add own themes to the themes folder, and that the plugin just scans the folder and list all entries in the directories.

Also it would be nice to have the possibility to save the preview HTML - not everyone has their own build infrastructure for markdown files, or uses it in Github or some other site - and just want to generate a HTML file easily.

@ghost
Copy link

ghost commented May 3, 2016

+1

@mpathy
Copy link
Author

mpathy commented May 3, 2016

Would be also okay if its just semiautomagically.. Like, moving some CSS to some folder and editing some config file.. Wouldnt even need UI for that..

@khatastroffik
Copy link

khatastroffik commented Feb 10, 2017

Straight forward - adding CSS themes:

  1. download a Markdown CSS theme file e.g. from markdown-css-themes
  2. save it to the plugin folder under X:\Users\"myaccount"\AppData\Roaming\Brackets\extensions\user\gruehle.markdown-preview\themes
  3. edit the file settings.html in X:\Users\"myaccount"\AppData\Roaming\Brackets\extensions\user\gruehle.markdown-preview\templates as in the following adding the Markdown7 and the Screen themes
...
<div class="md-settings-row">
        <span class="md-settings-label">Theme</span>
        <select id="markdown-preview-theme">
            <option value="clean">Light</option>
            <option value="dark">Dark</option>
            <option value="serif">Classic</option>
            <option value="markdown7">Markdown7</option> <!-- ADDED -->
            <option value="screen">Screen</option> <!-- ADDED -->
        </select>
    </div>
  1. reload/refresh Brackets Plugins (press [F5])
  2. voila !

Straight forward - exporting the Preview:

  1. right click within the preview panel -> "view souce".
  2. save the temporary file wherever you want.

Though, 2 imperfections here:

  • the path to the CSS doesn't match anymore
  • the path to the assets/images/... doesn't match anymore

Different "straight forward" solutions should work, depending on how/where you want to save or share those files... you may edit the preview.html in the plugin template directory and the main.js in the plugin root to match your needs... 😄
E.g.:
I modified the main.js file to re-define themeUrl (the baseUrl statement already exists...) so the html file now refer to the markdown preview plugin themes files correctly (html is not sharable but it can be saved locally on my system and the theme works).

// Make <base> tag for relative URLS
var baseUrl = window.location.protocol + "//" + FileUtils.getDirectoryPath(doc.file.fullPath);

// NEW LINE:
var themeUrl = window.location.protocol + "//" + require.toUrl("./themes/" + _prefs.get("theme") + ".css");

// Assemble the HTML source
var htmlSource = _.template(previewHTML)({
  baseUrl    : baseUrl,
  themeUrl   : themeUrl, // MODIFIED
  scrollTop  : scrollPos,
  bodyText   : bodyText
  });

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants