Skip to content

Commit

Permalink
feat: add config file
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermeprokisch committed Sep 3, 2024
1 parent f1d5078 commit 01aec09
Show file tree
Hide file tree
Showing 5 changed files with 268 additions and 38 deletions.
50 changes: 50 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ tempfile = "3.12.0"
lazy_static = "1.5.0"
include_dir = "0.7.4"
openssl-sys = { version = "0.9", features = ["vendored"] }
toml = "0.8.19"
dirs = "5.0.1"


# The profile that 'cargo dist' will build with
[profile.dist]
inherits = "release"
lto = "thin"

[dist]
allow-dirty = ["ci", "msi"]

# Config for 'cargo dist'
[workspace.metadata.dist]
Expand Down
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ As the project evolved, support for more complex Markdown features was added. Th
- Nested list support
- Blockquote styling
- And more adding soon!

## Installation

There are several ways to install smd:
Expand Down Expand Up @@ -143,6 +144,40 @@ smd --help

This command will render smd's main documentation file `/docs`, giving you a practical example of smd in action and providing detailed information about its usage and features.

# smd (Simple Markdown Viewer)

...

## Configuration

smd supports user-defined configuration files. You can customize various aspects of the rendering process by creating a `config.toml` file in the following location:

- On Linux and macOS: `~/.config/smd/config.toml`
- On Windows: `C:\Users\<USERNAME>\AppData\Roaming\smd\config.toml`

You can generate a default configuration file by running:

```bash
smd --generate-config
```

Here's an example of what you can configure:

```toml
theme = "default"
code_highlight_theme = "Solarized (dark)"
max_image_width = 40
max_image_height = 13
disable_images = false
disable_links = false
```

- `theme`: Overall color scheme (default: "default")
- `code_highlight_theme`: Theme for code syntax highlighting (default: "Solarized (dark)")
- `max_image_width` and `max_image_height`: Maximum dimensions for rendered images
- `disable_images`: If true, images will not be rendered
- `disable_links`: If true, links will not be clickable

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request. As this project is in alpha, your input and contributions can significantly shape its development.
Expand Down
46 changes: 37 additions & 9 deletions docs/main.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
smd: simple Markdown renderer
# smd: simple Markdown renderer

## Usage

Expand All @@ -10,17 +10,45 @@ If FILE is not provided, smd reads from standard input.

## Options

| | |
| ------------- | ------------------------------------ |
| `--debug` | Enable debug mode for verbose output |
| `--no-images` | Disable image rendering |
| `--help` | Display this help information |
| `--version` | Display version information |
| | |
| ------------------- | ------------------------------------- |
| `--debug` | Enable debug mode for verbose output |
| `--help` | Display this help information |
| `--version` | Display version information |
| `--generate-config` | Generate a default configuration file |

## Configuration

smd uses a configuration file located at:

- Linux/macOS: `~/.config/smd/config.toml`
- Windows: `%APPDATA%\smd\config.toml`

You can generate a default configuration file using the `--generate-config` option.

The configuration file allows you to customize various aspects of the rendering, including:

- Enabling/disabling image rendering
- Setting maximum image dimensions
- Choosing the code highlighting theme
- Enabling/disabling clickable links

## Examples

Render a Markdown file:
`smd path/to/your/markdown_file.md`

```bash
smd path/to/your/markdown_file.md
```

Render from standard input:
`echo "# Hello, world" | smd`

```bash
echo "# Hello, world" | smd
```

Generate a default configuration file:

```bash
smd --generate-config
```
Loading

0 comments on commit 01aec09

Please # to comment.