Skip to content

Custom modifications to the Gtk.SourceView Languages to support Markdown and syntax highlighting of code blocks in Markdown.

Notifications You must be signed in to change notification settings

ThiefMD/custom-gtksourceview-languages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom Gtk.SourceView Language Specs

This is a set of language specs used in ThiefMD

Changes

  • Markdown YAML Frontmatter support
  • Code block language highlighting support
  • Blockquote style applied to whole line
  • Support for ~~delete~~ tag
  • Support for footnotes
  • Fix reference/footnote from globbing link in same line
  • Change in XML and HTML comment styling

Usage

In this example, we packages the language-specs in our Build.PKGDATADIR/gtksourceview-4/language-specs.

    Gtk.SourceLanguageManager thief_languages;
    public Gtk.SourceLanguageManager get_language_manager () {
        if (thief_languages == null) {
            thief_languages = new Gtk.SourceLanguageManager ();
            string custom_languages = Path.build_path (
                Path.DIR_SEPARATOR_S,
                Build.PKGDATADIR,
                "gtksourceview-4",
                "language-specs");
            string[] language_paths = {
                custom_languages
            };
            thief_languages.set_search_path (language_paths);

            var markdown = thief_languages.get_language ("markdown");
            if (markdown == null) {
                warning ("Could not load custom languages");
                thief_languages = Gtk.SourceLanguageManager.get_default ();
            }
        }

        return thief_languages;
    }

Inside of our editor, we can do:

var languages = get_language_manager ();
var markdown_syntax = languages.get_language ("markdown");
Gtk.SourceBuffer buffer = new Gtk.SourceBuffer.with_language (markdown);
Gtk.SourceView view = new Gtk.SourceView.with_buffer (buffer);

Credits

About

Custom modifications to the Gtk.SourceView Languages to support Markdown and syntax highlighting of code blocks in Markdown.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published