Metadata-Version: 2.4
Name: ckanext-markdown_view
Version: 1.0.3
Summary: Extension to automate mapping of csvw meta data documents to knowledge graphs and run automatic pipelines by testing for compatible mapping present in ckan, uses mat-o-lab tools MaptoMethod and RDFConverter.
Author-email: Thomas Hanke <thomas.hanke@iwm.fraunhofer.de>
License: AGPL
Project-URL: Homepage, https://github.com/Mat-O-Lab/ckanext-markdown_view
Keywords: CKAN,MARKDOWN,MD,VIEW
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

[![Tests](https://github.com/Mat-O-Lab/ckanext-markdown_view/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/Mat-O-Lab/ckanext-markdown_view/actions/workflows/test.yml)

# ckanext-markdown_view
a CKAN extension creating previews for markdown files


## Requirements

## Purpose

### Notes:


Compatibility with core CKAN versions:

| CKAN version    | Compatible?   |
| --------------- | ------------- |
| 2.9 and arlier  | not tested    |
| 2.10             | yes    |
| 2.11            | yes    |

* "yes"
* "not tested" - I can't think of a reason why it wouldn't work
* "not yet" - there is an intention to get it working
* "no"

## Installation

To install the extension:

1. Activate your CKAN virtual environment, for example:
```bash
. /usr/lib/ckan/default/bin/activate
```
2. Use pip to install package
```bash
pip install ckanext-markdown_view
```
3. Add `markdown_view` to the `ckan.plugins` setting in your CKAN
   config file (by default the config file is located at
   `/etc/ckan/default/ckan.ini`).

4. Restart CKAN. For example, if you've deployed CKAN with Apache on Ubuntu:
```bash
sudo service apache2 reload
```

## Config settings

You can set the default formats to preselected for upload by setting the formats,
```bash
CKANINI__CKANEXT__MARKDOWN__FORMATS = 'text/markdown'
```
else it will react to the listed formats by default

## Features

### List-Aware Markdown Rendering

This extension overrides CKAN's core `render_markdown` helper to automatically handle list/tuple data structures. This is particularly useful when using ckanext-scheming with the `multiple_text` preset, which stores field values as lists.

**Problem Solved:** When scheming fields use both `preset: multiple_text` and `display_snippet: markdown.html`, the core CKAN helper would crash with `AttributeError: 'list' object has no attribute 'strip'`.

**Solution:** The custom `render_markdown` helper automatically converts lists to newline-separated strings before rendering as markdown, providing seamless compatibility with scheming's multiple_text fields.

Example field that now works correctly:
```yaml
- field_name: rights
  label: Rights
  form_snippet: markdown.html
  display_snippet: markdown.html
  preset: multiple_text
  validators: ignore_missing scheming_multiple_text
```

## Highlight View
Each resource can be rendered by highlighting some markdown passage.
The markdown content to highlight must be passed as post to the /highlight url, for example:
```bash
curl -X POST 'https://<ckan_url>/dataset/<dataset_d>/resource/<res_id>/highlight' -F highlight="<markdown code to highlight>"
```


