项目技术文档——Acts as Markup
2024-12-23 05:28:47作者:姚月梅Lane
1. 安装指南
首先,你需要将 acts_as_markup 添加到你的 Gemfile 中:
gem "acts_as_markup"
然后,运行以下命令进行安装:
bundle install
确保你已经安装了以下库,因为它们是项目所必需的:
- RedCloth:用于处理 Textile 文本。
- BlueCloth、RDiscount、Ruby PEG、Maruku 或 Redcarpet:作为 Markdown 处理器。
2. 项目的使用说明
本项目允许你在 ActiveRecord 模型中指定包含 Markdown、Textile 和 RDoc 的列。你可以使用 to_s 方法获取原始标记文本,或使用 to_html 方法获取格式化后的 HTML。
此外,你可以有一个模型,其中包含一个列,它包含一个标记文本的列,另一个列定义了要处理它的语言。如果字段被列为 "markdown"、"textile" 或 "rdoc"(不区分大小写),它将以此处理,对于标记语言的任何其他值,将作为普通字符串传递。
此 AR 扩展可以使用五种不同的 Markdown 处理后端:BlueCloth、RDiscount、Ruby PEG、Redcarpet 或 Maruku。你可以在环境配置文件(environment.rb)中设置一个配置值来指定你想使用的库:
ActsAsMarkup.markdown_library = :bluecloth
默认情况下将使用 RDiscount。
3. 项目API使用文档
以下是一些示例用法:
使用 acts_as_markdown
class Post < ActiveRecord
acts_as_markdown :body
end
@post = Post.find(:first)
@post.body.to_s # => "## Markdown Headline"
@post.body.to_html # => "<h2> Markdown Headline</h2>"
使用 acts_as_textile
class Post < ActiveRecord
acts_as_textile :body
end
@post = Post.find(:first)
@post.body.to_s # => "h2. Textile Headline"
@post.body.to_html # => "<h2>Textile Headline</h2>"
使用 acts_as_rdoc
class Post < ActiveRecord
acts_as_rdoc :body
end
@post = Post.find(:first)
@post.body.to_s # => "== RDoc Headline"
@post.body.to_html # => "<h2>RDoc Headline</h2>"
使用 acts_as_markup
class Post < ActiveRecord
acts_as_markup :language => :markdown, :columns => [:body]
end
@post = Post.find(:first)
@post.body.to_s # => "## Markdown Headline"
@post.body.to_html # => "<h2> Markdown Headline</h2>"
使用带 :variable 语言的 acts_as_markup
class Post < ActiveRecord
acts_as_markup :language => :variable, :columns => [:body]
end
@post = Post.find(:first)
@post.markup_language # => "markdown"
@post.body.to_s # => "## Markdown Headline"
@post.body.to_html # => "<h2> Markdown Headline</h2>"
使用选项
class Post < ActiveRecord
acts_as_markdown :body, :markdown_options => [ :filter_html ]
end
class Post < ActiveRecord
acts_as_textile :body, :textile_options => [ [ :filter_html ] ]
end
4. 项目安装方式
请遵循上述安装指南。简要概括如下:
- 将
acts_as_markup添加到 Gemfile 中。 - 运行
bundle install。 - 根据需要配置 Markdown 库。
确保所有必需的依赖项都已正确安装。
登录后查看全文
热门项目推荐
atomcodeClaude Code 的开源替代方案。连接任意大模型,编辑代码,运行命令,自动验证 — 全自动执行。用 Rust 构建,极致性能。 | An open-source alternative to Claude Code. Connect any LLM, edit code, run commands, and verify changes — autonomously. Built in Rust for speed. Get StartedRust0237
GLM-5.2智谱开源 GLM-5.2,这是针对长文本任务的最新旗舰模型。相较于前代产品 GLM-5.1,它在长文本任务处理能力上实现了显著飞跃,并且首次在稳定的 100 万 token 上下文中提供这一能力。Jinja00
JoyAI-VL-Interaction-Preview京东开源首个开源、视觉驱动的实时交互模型——它能实时监控视频流,并自主决定何时发言、保持沉默或委托任务。Jinja00
cann-learning-hubCANN 学习中心仓,支持在线互动运行、边学边练,提供教程、示例与优化方案,一站式助力昇腾开发者快速上手。Jupyter Notebook0165
kornia🐍 空间人工智能的几何计算机视觉库Python03
PaddleParallel Distributed Deep Learning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)C++02
项目优选
收起
暂无描述
Dockerfile
783
5.13 K
本项目是CANN提供的transformer类大模型算子库,实现网络在NPU上加速计算。
C++
893
2.06 K
Ascend Extension for PyTorch
Python
764
983
本项目是CANN提供的神经网络类计算算子库,实现网络在NPU上加速计算。
C++
713
1.44 K
deepin linux kernel
C
32
16
openEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。
C
471
477
CANN 学习中心仓,支持在线互动运行、边学边练,提供教程、示例与优化方案,一站式助力昇腾开发者快速上手。
Jupyter Notebook
468
165
本项目是CANN提供的数学类基础计算算子库,实现网络在NPU上加速计算。
C++
1.11 K
1.16 K
JiuwenSwarm 是一款基于openJiuwen开发的智能AI Agent,它能够将大语言模型的强大能力,通过你日常使用的各类通讯应用,直接延伸至你的指尖。
Python
2.42 K
683
昇腾LLM分布式训练框架
Python
187
239