gedit-markdown: support du langage Markdown dans gedit

原文:http://www.jpfleury.net/en/software/gedit-markdown.php

Overview

gedit-markdown adds support for Markdown (or Markdown Extra)
in gedit, the default Gnome text editor.

Specifically, it adds:

  • Markdown syntax highlighting and snippets;
  • plugin Markdown Preview for gedit, displayed in the side panel or the bottom panel and previewing in HTML the current document or selection (this plugin can also be used as a Web browser; see section Usage);
  • an external tool exporting to HTML the current document or selection;
  • a color scheme, optional, highlighting Markdown files in a manner more similar to HTML rendering.

Requirements

  • gedit-markdown supports gedit 2 and gedit 3. It's shipped with an installer for GNU/Linux. On Windows XP, only a few files work, and must be installed by hand.
  • The plugin Markdown Preview depends on Python 2 (>= 2.6) or Python 3 (>= 3.1), although for now gedit only supports Python 2. The installer will copy the plugin only if the right version of Python is installed.
  • Deactivation of check spelling for irrelevant highlighted contexts (for example in URL) depends on GtkSourceView >= 2.10.
  • For users of Ubuntu 11.10 or later: the package gir1.2-webkit-3.0 must be installed to use the plugin Markdown Preview.

Installation (or update)

GNU/Linux

Markdown support will be added for the current user (so no need root privileges). The folder created by the extraction can be deleted after installation.

Windows XP

Here are steps for gedit 2:

  • Syntax highlighting: in the extracted folder, find the folder language-specs, copy the file corresponding to the Markdown version
    desired, for example:

    language-specs/markdown.lang
    

    and paste it in the following folder:

    C:\Program Files\gedit\share\gtksourceview-2.0\language-specs\
    
  • Optional color scheme: in the extracted folder, copy the file styles/classic-markdown.xmland paste it in the following folder:
    C:\Program Files\gedit\share\gtksourceview-2.0\styles\
    

Uninstallation

GNU/Linux

  • Open a terminal in the extracted folder.
  • Run the uninstaller in the terminal:
    ./gedit-markdown.sh uninstall
    

Tip: it's possible to specify in command line the version of gedit. Possible values ​​are 2 and 3.
It can be useful when updating from gedit 2 to gedit 3. Thus, the script can be run to remove files from the old version of gedit. Example:

./gedit-markdown.sh uninstall 2

Windows XP

Simply remove by hand the files added during installation.

Usage

First of all, restart gedit if it's already running.

Syntax highlighting

Syntax highlighting should automatically be activated for files recognized as Markdown files (extensions .markdown.md or .mkd),
otherwise choose it manually by going to View > Highlight Mode > Markup and selecting Markdown.

Plugin Markdown Preview

To enable this plugin, go to Edit > Preferences > Plugins and check Markdown Preview.

Two items are added in the gedit menu Tools:

  • Update Markdown Preview: displays in the side panel or in the bottom panel a preview in HTML of the current document or selection.

    Note: there are two other ways to update preview:

    • with the keyboard shortcut Ctrl+Alt+m (can be changed in the configuration file);
    • by right clicking on the preview area (side or bottom panel) and selecting the item Update Preview (gedit 3 only).
  • Toggle Markdown Preview visibility: allows to display or hide the Markdown Preview panel tab.

    Note: the keyboard shortcut Ctrl+Alt+v (can be changed in the configuration file) can be used to do the same.

If gedit 3 is used, when right clicking on the preview area, a context menu appears and lists several options. Besides the default ones (previous page, next page, copy, etc.), we have:

  • Copy the current URL: copy in the clipboard the URL of the document or the page being displayed in the preview tab. If it's a document that has not yet been saved to disk, this menu item is disabled.
  • Go to another URL: allows to manually enter a local or distant URL of a document or page to visit in the preview tab.
  • One of the following two options, depending on the value of the property externalBrowser in the configuration file:
    • Open in an external browser: allows to open the link in an external browser.
    • Open in the embedded browser: allows to open the link in the panel.
  • Update Preview: reloads in the side panel or in the bottom panel the preview in HTML of the current document or selection.
  • Clear Preview: clear content of the preview tab.

Here's a screenshot of the plugin when it's displayed in the bottom panel:

Now the same plugin displayed in the side panel (click to download the original image):

Note that when the cursor passes over a link in the preview area, a tooltip displays the URL:

Snippets

To use Markdown snippets, activate the plugin Snippets in Edit > Preferences > Plugins. Then, go toTools > Manage Snippets... to see the possibilities.

External tool Export to HTML

To use the external tool, activate the plugin External Tools in Edit > Preferences > Plugins. Then, go to Tools > External Tools > Export to HTML to access the tool. The keyboard shortcut Ctrl+Alt+hdoes
the same. The code of the currently opened Markdown file or the selection will be converted in HTML, and the result will be put in a new document.

To edit the tool, go to Tools > Manage External Tools....

Optional color scheme

An optional color scheme is installed by gedit-markdown. To use it, go to Edit > Preferences > Font & Colors > Color Scheme in gedit and select Classic Markdown. This color scheme is more similar to an HTML rendering,
for example strong emphases and headers are in bold and black font, links are blue and underlined, etc. Here's a screenshot of a Markdown document highlighted with this color scheme:

Configuration file

The configuration file of gedit-markdown is the following:

$XDG_CONFIG_HOME/gedit/gedit-markdown.ini

Most of the time, it will correspond to:

$HOME/.config/gedit/gedit-markdown.ini

Only the section markdown-preview can be edited. It contains several properties:

  • externalBrowser: open links in an external browser by default. Possible values: 0 (don't
    open links in an external browser by default; default value) or 1 (open links in an external browser by default).

    If externalBrowser has a value of 0,
    the context menu displayed when right clicking on a link will contain an option to open the link in an external browser. If externalBrowser equals 1,
    the context menu will contain an option to open the link in the embedded browser.

  • panel: emplacement of the preview. Possibles values: side or bottom.
  • shortcut: shortcut to refresh the preview. The default value is <Control><Alt>m.
  • version: the Markdown version to use for the HTML preview and to export to HTML. Possible values: standard or extra.
  • visibility: visibility of the Markdown Preview panel tab when gedit starts. Possible values: 0(hidden)
    or 1 (displayed; default value).
  • visibilityShortcut: shortcut to toggle Markdown Preview visibility. The default value is<Control><Alt>v.

Details and limitations

  • Syntax highlighting and snippets for standard Markdown were officially added in GtkSourceView and gedit > 3.1.1. The installer of gedit-markdown will ensure that no already existing files are copied (no check is done for Markdown Extra because this is not
    the default version shipped with GtkSourceView and gedit > 3.1.1).
  • Older versions of gedit-markdown also added Markdown MIME type and recognition of an additional extension (.mdtxt). Since Markdown
    support was added directly into the shared MIME database shared-mime-info (see
    the bug report
    ), gedit-markdown no longer adds its own Markdown MIME type file. Also, for purposes of compliance with the specification, the extension .mdtxt is
    no longer supported.
  • Since HTML code can be directly used in a text written in Markdown, HTML syntax highlighting was added to Markdown syntax highlighting. However, keep in mind that, even if they're highlighted, Markdown syntax within HTML blocks (e.g. <div>)
    and Markdown Extra syntax within HTML blocks without markdown attribute set to 1 (e.g., <div
    markdown="1">
    ) are not processed.
  • Within a paragraph, text wrapped with backticks indicates a code span. Markdown allows to use one or more backticks to wrap text, provided that the number is identical on both sides, and the same number of consecutive backticks is not present within the
    text. Examples:

    `lorem lorem lorem lorem`
    
    `lorem lorem `` lorem lorem`
    
    `lorem lorem ````` lorem lorem`
    
    ``lorem lorem lorem lorem``
    
    ``lorem lorem ` lorem lorem``
    
    ``lorem lorem ````` lorem lorem``
    

    Syntax highlighting in gedit supports code span highlighting with up to 2 backticks surrounding text.

  • Blockquote can contain block-level and inline Markdown elements, but gedit-markdown only highlights inline ones (emphasis, link, etc.).
  • A full context analysis can't be done (because line break can't be used in regex). Here are some consequences:
    • According to the Markdown syntax, to write several paragraphs in a list item, we have to indent each paragraph. Example:

      - Item A (paragraph 1).
      
          Item A (paragraph 2).
      
          Item A (paragraph 3).
      
      - Item B.
      

      So there is a conflict in terms of syntax highlighting between an indented paragraph inside a list item (4 spaces or 1 tab) and an indented line of code outside a list (also 4 spaces or 1 tab). The choice was made ​​​​to highlight code block only from 2
      levels of indentation.

    • Only the underline of a Setext-style header is matched and highlighted, so there's no guarantee that it's indeed a title underline.
    • With Markdown Extra, some elements are matched and highlighted with no guarantee that they're in the right context: Setext-style header id attribute, colon used as separator in a definition list and separator line of a table.

Localization

gedit-markdown installer is translatable. Anyone interested in the translation can copy the filegedit-markdown.pot in
the folder locale, rename it to LANG.po,
translate all strings and send me the result.

Similarly, the plugin Markdown Preview is also localizable. The file containing strings isplugins/markdown-preview/locale/markdown-preview.pot.

For now, gedit-markdown is available in French and English.

Development

Last version: 1.4.1 (2013-01-17)

Git is used for revision control. Repository can be browsed online or cloned.

gedit-markdown has an issue tracker, on which bug reports and feature requests can be submitted.

License

Author: Jean-Philippe Fleury contact@jpfleury.net
Copyright 2009-2012 Jean-Philippe Fleury

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Third-party code

时间: 2024-12-09 17:35:06

gedit-markdown: support du langage Markdown dans gedit的相关文章

OpenCASCADE Documentation System

OpenCASCADE Documentation System eryar@163.com Abstract. Doxygen is the de facto standard tool for generating documentation from annotated C++ sources, but it also supports other popular programming languages. You can also use doxygen for creating no

Markdown Cheatsheet

原文:https://github.com/adam-p/markdown-here/wiki/Markdown-Here-Cheatsheet Markdown Cheatsheet This is intended as a quick reference and showcase. For more complete info, see John Gruber's original spec and the Github-flavored Markdown info page. Note

Haskell ghci中如何调用pandoc的API进行markdown转换

所用环境:Windows Server 2008 + ghc 7.6.3(Haskell Platform 2013.2.0.0自带的) + pandoc 1.12.4 操作步骤: 1. 安装Haskell Platform,下载地址:http://www.haskell.org/platform/. 2. 安装pandoc,安装命令:cabal install pandoc 3. 在命令行中运行ghci 4. 引用pandoc的相应模块,在Prelude命令提示符中运行: :module Te

78 款 Markdown 工具

Markable 强大的在线 Markdown 编辑器,支持语法高亮.自动缩进.高亮所在行.显示行数.即时预览.它支持将 HTML 转换成 Markdown. 可以配合 Evernote.Dropbox 使用. Markdown Here 使用 Markdown 撰写邮件.可以插入表格.代码片段和数学公式.支持 Chrome.Firefox.Safari 和 Thunderbird. MultiMarkdown Composer Mac OS X 下的 Markdown 编辑器,支持 Multi

MarkDown 语法手册

From: http://blog.leanote.com/post/freewalk/Markdown-%E8%AF%AD%E6%B3%95%E6%89%8B%E5%86%8C From: http://www.jianshu.com/p/1e402922ee32/ Markdown 是一种用来写作的轻量级「标记语言」,它用简洁的语法代替排版,而不像一般我们用的字处理软件 Word 或 Pages 有大量的排版.字体设置.它使我们专心于码字,用「标记」语法,来代替常见的排版格式.例如此文从内容

8个优秀的开源Markdown编辑器

Markdown 首先,对 Markdown 进行一个简单的介绍.Markdown 是由 John Gruber 和 Aaron Swartz 共同创建的一种轻量级纯文本格式语法.Markdown 可以让用户"以易读.易写的纯文本格式来进行写作,然后可以将其转换为有效格式的 XHTML(或 HTML)".Markdown 语法只包含一些非常容易记住的符号.其学习曲线平缓;你可以在炒蘑菇的同时一点点学习 Markdown 语法(大约 10 分钟).通过使用尽可能简单的语法,错误率达到了最

All Things Markdown

概述 Markdown 是一种轻量级标记语言,创始人为约翰·格鲁伯(John Gruber)和亚伦·斯沃茨(Aaron Swartz).它允许人们"使用易读易写的纯文本格式编写文档,然后转换成有效的XHTML(或者HTML)文档".这种语言吸收了很多在电子邮件中已有的纯文本标记的特性. 特点 兼容 HTML 要在Markdown中输写HTML区块元素,比如<div>.<table>.<pre>.<p> 等标签,必须在前后加上空行与其它内容

选择使用正确的 Markdown Parser

本文讲的是选择使用正确的 Markdown Parser, 以下客座文章由Ray Villalobos提供.在这篇文章中Ray将要去探索很多种不同的Markdown语法.所有的这些MarkDown变种均提供了不同的特性,都超越传统的Markdown语法,却又相互之间又各有不同.如果你正在挑选一门Markdown语言使用(或是提供给你的Web产品的用户使用),那你就值得的去了解它们,一旦选定就很难再切换到别的Markdown版本而且挑选的结果依赖于你需要哪些特性.Ray提供的一门关于MarkDow

CSDN Markdown简明教程-表格和公式

表格 Markdown使用管线图的方式实现表格,表格里面可以使用强调.链接等行内格式. 下面代码所示为一个基本的表格: 教程标题| 主要内容 -------|---------- 关于Markdown | 简介Markdown,Markdown的优缺点 Markdown基础 | Markdown的**基本语法**,格式化文本.代码.列表.链接和图片.分割线.转义符等 Markdown表格和公式 | Markdown的**扩展语法**,表格.公式 效果 教程标题 主要内容 关于Markdown 简