You are here: start » en » Internal Documentation » DokuWiki extensions (WvdS) » Source Viewer » Quickstart: show a source file on a page

Quickstart: show a source file on a page

The shortest way from “the plugin is installed” to “a file is on a wiki page with syntax highlighting and line numbers”. Three steps, about five minutes.

Prerequisites

  • wksourceview is installed and enabled in the Extension Manager.
  • You may read the file. The plugin checks read permission on every request: what you cannot open in the media manager will not render here either.
  • You may edit a page.

Step 1: upload a file

Open the media manager (/doku.php?do=media), create the namespace dev and upload a source file, for example sample.php.

The media id is then dev:sample.php.

Step 2: embed it

Edit a page and write:

{{source>media:dev:sample.php}}

media: names the provider that resolves the rest. Built in are media: (the media store) and page: (the source text of a wiki page); git: and ado: arrive with the wkdogit and wkdoadogit plugins.

Step 3: narrow it to the lines that matter

A whole file is rarely the point. Append a line range:

{{source>media:dev:sample.php#L10-L40}}
Fragment Shows
#L25 line 25 only
#L10-L40 lines 10 to 40, inclusive
#L10- line 10 to the end of the file

A range reaching past the end of the file is clamped to the last line — it yields the remainder rather than an error.

Check the result

  • The block is on the page, highlighted and numbered. The language was detected from the file extension.
  • The block's heading names the file and links to it.
  • Every line carries an anchor: click a line number and you get an address pointing at exactly that line.

If instead you see a short unavailable notice, a download link or unhighlighted plain text, the file was found but something declined to render it as source — the causes and remedies are on the package page.

Next step

  • wkdoadogit — the same display for files from an Azure DevOps repository.
  • wkdogit — the same for a local repository on the server.
  • wksourceview (German) — the package page: the full grammar of a reference, the render modes and the max_bytes / max_lines ceilings.
en/wiki/dwe/wksourceview/quickstart.txt · Last modified: by 0.0.0.0