承接 dsnr/obsidian-commonmark-extension 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dsnr/obsidian-commonmark-extension

最新稳定版本:v0.0.3

Composer 安装命令:

composer require dsnr/obsidian-commonmark-extension

包简介

A league/commonmark extension to parse obsidian markdown to html

README 文档

README

obsidian-commonmark-extension is a custom extension for the CommonMark markdown parser that adds a new inline element and renderer for displaying images with a configurable base URL. A new inline element and parser for obsidian style links and anchors

Installation

You can install the extension using Composer:

composer require dsnr/obsidian-commonmark-extension

Usage

To use the extension, create a new League\CommonMark\Environment\Environment instance, register the extension with the addExtension() method, and pass the environment to a new League\CommonMark\CommonMarkConverter instance:

The extension expects the image file names to be kebab cased eg. example-image.ong

use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment\Environment;
use Dsnr\ObsidianCommonmarkExtension\ObsidianConverterExtension;


$environment = new Environment();
  $environment->addExtension(new ObsidianConverterExtension());

$converter = new CommonMarkConverter([], $environment);

echo $converter->convertToHtml('![[Example Image.png]]);

Configuration

obsidian-commonmark-extension includes a configuration schema that defines the obsidian.image_base_url option as a string type with an empty default value. You can modify this option by passing an array of configuration options.

By default, the extension's image base URL is an empty string, so the image URL will be displayed exactly as written. To set a custom image base URL, set the obsidian.image_base_url :

use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment\Environment;
use Dsnr\ObsidianCommonmarkExtension\ObsidianConverterExtension;

$config = [
  'obsidian' => [
    'base_image_path' => asset('/images/')
  ]
];

$environment = new Environment($config);
$environment->addExtension(new ObsidianConverterExtension());

$converter = new CommonMarkConverter([], $environment);

echo $converter->convertToHtml('![[Example Image.png]]);

License

obsidian-commonmark-extension is licensed under the MIT license.

Please let me know if you need any further modifications or clarifications in the readme file.

统计信息

  • 总下载量: 62
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-08