Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,41 @@ This gem exists largely to handle a GOV.UK Forms service use case and is unlikel

TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.

Install the gem and add to the application's Gemfile by executing:
Add the gem to your Gemfile:

$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
```ruby
gem "govuk-forms-markdown", require: "govuk_forms_markdown", github: "alphagov/govuk-forms-markdown", tag: "0.8.0" # Check the Github releases for the latest tag
```

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
Then run `bundle install`.

## Usage

TODO: Write usage instructions here
The `render` method will return HTML when provided with a markdown string.

```ruby
# Call the render method with the markdown you want to render
GovukFormsMarkdown.render(markdown)

# You can configure it to disallow headings
GovukFormsMarkdown.render(markdown, allow_headings: false)

# You can configure it if you're passing Welsh language markdown
GovukFormsMarkdown.render(markdown, locale: "cy")
```

The `validate` method will return HTML when provided with a markdown string.

```ruby
# Call the validate method with the markdown you want to render
GovukFormsMarkdown.validate(markdown)

# You can configure it to disallow headings
GovukFormsMarkdown.validate(markdown, allow_headings: false)

# It will return a JSON object containing a list of errors:
{ errors: [:too_long, :unsupported_tags_used] }
```

## Development

Expand Down
3 changes: 2 additions & 1 deletion govuk-forms-markdown.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Gem::Specification.new do |spec|
spec.license = "MIT"
spec.required_ruby_version = ">= 3.4.6"

spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
# This configures which hosts you can publish to - but we're not publishing anywhere
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/alphagov/govuk-forms-markdown"
Expand Down