Giter VIP home page Giter VIP logo

wikimarkdown's Introduction

About

This is a MediaWiki extension that allows for markdown syntax to be used on wiki pages. More information can be found on the extension page.

Requirements

This version of the extension has been tested with Parsedown 1.7.4, Parsedown Extra 0.8.1, and MediaWiki 1.35.

Installation

Add this line to your LocalSettings.php:

wfLoadExtension( 'WikiMarkdown' );

This extension requires Parsedown to be installed and optionally Parsedown Extra and Parsedown Extended. Either install them manually, or use Composer by adding the line "extensions/WikiMarkdown/composer.json" to the "composer.local.json" file in the root directory of your wiki, e.g.

{
	"extra": {
		"merge-plugin": {
			"include": [
				"extensions/WikiMarkdown/composer.json"
			]
		}
	}
}

Then run composer update in the root directory of your wiki.

Usage

On wiki pages, you can now use <markdown> elements:

<markdown>
## Emphasis

**This is bold text**

__This is bold text__

*This is italic text*

_This is italic text_

~~Strikethrough~~
</markdown>

Parameters

  • inline: Indicates that inline-style markdown should be used instead of block-style.

Configuration

  • $wgAllowMarkdownExtra (optional): Set to true in order to specify that Parsedown Extra should be used.
  • $wgAllowMarkdownExtended (optional): Set to true in order to specify that Parsedown Extended should be used.
  • $wgParsedownExtendedParameters (optional): Allows for specifying the options that are passed to Parsedown Extended. See the documentation for which options you want to enable or disable.

Other Features

  • This extension also functions as a content handler for wiki pages ending in .md. For these pages, the entire page will be interpreted as markdown and markdown syntax highlighting will be used in the editor if you have the CodeEditor extension installed.
  • When specifying code blocks in markdown, this extension will automatically apply the SyntaxHighlight extension if it is installed. All languages supported by the SyntaxHighlight extension will work.
  • When using Parsedown Extended, this extension will automatically apply the Math extension if it is installed to any math blocks by default. This can be turned off by either not using Parsedown Extended, or modifying $wgParsedownExtendedParameters. The following syntaxes are valid: \[ ... \]/$$ ... $$ (for block mode) and \( ... \)/$ ... $ (for inline mode)
  • When using the VisualEditor extension with the CodeEditor extension, markdown blocks will be editable using a markdown editor.

Credits

wikimarkdown's People

Contributors

kuenzign avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wikimarkdown's Issues

Release wikimarkdown

Hello I was wondering will there be an official release instead of just downloading the master branch?

img tags within links are encoded as HTML entities

This particular occurs on my instance for badges, e. g.

[![DOI](https://zenodo.org/badge/458130867.svg)](https://zenodo.org/badge/latestdoi/458130867)\

generates

<a rel="nofollow" class="external text" href="https://zenodo.org/badge/latestdoi/458130867">&lt;img src="https://zenodo.org/badge/458130867.svg" alt="DOI" /&gt;</a>

instead of

<a rel="nofollow" class="external text" href="https://zenodo.org/badge/latestdoi/458130867"><img src="https://zenodo.org/badge/458130867.svg" alt="DOI" /></a>

Setting $escape = true solves the problem (see docs) - would that be a solution?

return Linker::makeExternalLink($cleanUrl, $text, true, $linkType, $parser->getExternalLinkAttribs($url), $parser->getTitle());

unable to link to page headings

Hi there, thank you for this extension! I've been relegated to have to write in documentation in "wiki text/format" at my company and this extension has finally set me free. lol 😄

I've noticed a couple of things that are different when writing pages in markdown. I'm wondering if they are configuration errors on my end.

  1. I'm not sure if there are some table of contents specific tweaks that need to be made in order to support markdown, however it seems that the table of contents isn't created anymore.
  2. if i link to other markdown headings within the same page, or on a different markdown page, the links don't actually take you to the heading. For example if i have a heading ## Delete a Branch, I would expect to be able to create a link later on in document like this [delete the branch](#delete-a-branch) and when I click on it, have it take me to on the point on the page where that heading is. However this doesn't happen; clicking the link does nothing when on the same page. When the link is a different markdown page, it just takes me to the top of that page.

Again, thanks for the great extension!

Deprecation warning with MediaWiki 1.35+

Deprecated: Use of Parser::enableOOUI was deprecated in MediaWiki 1.35. [Called from WikiMarkdown::parserHook in
XXX\wiki\extensions\WikiMarkdown\includes\WikiMarkdown.php at line 110] in XXX\wiki\includes\debug\MWDebug.php on line 377

Env:

Installed software
Product Version
MediaWiki 1.38.2
PHP 8.1.6 (apache2handler)
MariaDB 10.4.24-MariaDB
ICU 70.1
Lua 5.1.5
Pygments 2.11.2

Fails on installation

composer update
> ComposerHookHandler::onPreUpdate
Loading composer repositories with package information
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Info from https://repo.packagist.org: #StandWithHihils
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for doctrine/dbal 3.4.2 -> satisfiable by doctrine/dbal[3.4.2].
    - doctrine/dbal 3.4.2 requires composer-runtime-api ^2 -> no matching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Option to embed wiki markup nested within markdown?

Similarly to how github does it, it would be nice to be able to embed nested html / wiki markup tags within <markdown> tags.

I don't think there should be a security concern? Presumably mediawiki prevents users from uploading malicious tags. Not sure if the parser_hook hooks into mediawiki rendering or goes straight to html...

Call to undefined method mathTagHook()

With Math enabled, if I save the page with $$ section in <markdown>, the page will be like this:

[cc9dd1222bfb599d83029366] /index.php?title=%E6%96%87%E6%9C%AC%E6%A0%B7%E5%BC%8F%E7%A4%BA%E4%BE%8B&action=submit Error: Call to undefined method MediaWiki\Extension\Math\Hooks::mathTagHook()

Backtrace:

from /home/wwwroot/wiki/extensions/WikiMarkdown/includes/WikiMarkdown.php(155)
#0 [internal function]: WikiMarkdown::{closure}()
#1 /home/wwwroot/wiki/extensions/WikiMarkdown/includes/WikiMarkdown.php(157): preg_replace_callback()
#2 /home/wwwroot/wiki/includes/parser/Parser.php(3979): WikiMarkdown::parserHook()
#3 /home/wwwroot/wiki/includes/parser/PPFrame_Hash.php(353): Parser->extensionSubstitution()
#4 /home/wwwroot/wiki/includes/parser/Parser.php(2932): PPFrame_Hash->expand()
#5 /home/wwwroot/wiki/includes/parser/Parser.php(1579): Parser->replaceVariables()
#6 /home/wwwroot/wiki/includes/parser/Parser.php(697): Parser->internalParse()
#7 /home/wwwroot/wiki/includes/content/WikitextContentHandler.php(294): Parser->parse()
#8 /home/wwwroot/wiki/includes/content/ContentHandler.php(1705): WikitextContentHandler->fillParserOutput()
#9 /home/wwwroot/wiki/includes/content/Renderer/ContentRenderer.php(47): ContentHandler->getParserOutput()
#10 /home/wwwroot/wiki/includes/EditPage.php(4254): MediaWiki\Content\Renderer\ContentRenderer->getParserOutput()
#11 /home/wwwroot/wiki/includes/EditPage.php(4157): EditPage->doPreviewParse()
#12 /home/wwwroot/wiki/includes/EditPage.php(2926): EditPage->getPreviewText()
#13 /home/wwwroot/wiki/includes/EditPage.php(728): EditPage->showEditForm()
#14 /home/wwwroot/wiki/includes/actions/EditAction.php(71): EditPage->edit()
#15 /home/wwwroot/wiki/includes/actions/SubmitAction.php(38): EditAction->show()
#16 /home/wwwroot/wiki/includes/MediaWiki.php(543): SubmitAction->show()
#17 /home/wwwroot/wiki/includes/MediaWiki.php(321): MediaWiki->performAction()
#18 /home/wwwroot/wiki/includes/MediaWiki.php(912): MediaWiki->performRequest()
#19 /home/wwwroot/wiki/includes/MediaWiki.php(563): MediaWiki->main()
#20 /home/wwwroot/wiki/index.php(53): MediaWiki->run()
#21 /home/wwwroot/wiki/index.php(46): wfIndexMain()
#22 {main}

Is it caused by some version mismatch? I'm currently using

  • MediaWiki 1.38.4
  • PHP 7.4.30
  • WikiMarkdown 1.1.3 (642e707) 2022-08-15
  • Math 3.0.0
  • SyntaxHighlight 2.0 (it works fine with markdown)
  • benjaminhoegh/parsedown-extended 1.1.2
  • erusev/parsedown 1.8.0b7
  • erusev/parsedown-extra 0.8.1

Handling Wikilinks?

Hello! I'm curious how i would go about extending this extension to support wikilinks?

Currently a block like this:

<markdown>
- [[WikiLink1]]
- [[WikiLink2]]
</markdown

Will render literally like

  • [[WikiLink1]]
  • [[WikiLink2]]

Instead of making them wikilinks. The typical Markdown syntax of [text](url) makes external links, which don't handle relative links within the wiki or engage the wiki tools for eg. "wanted links" or "what links here"

It seems like it should be possible to parse and insert actual wikilinks with double brackets since they're not part of markdown syntax, how would i go about doing that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.