Metadata-Version: 2.1
Name: hubspot-tech-writing
Version: 0.1.0
Summary: Support technical writing on HubSpot using Markdown.
Author-email: Andreas Motl <andreas.motl@crate.io>
License: Apache License 2.0
Project-URL: changelog, https://github.com/crate-workbench/hubspot-tech-writing/blob/main/CHANGES.md
Project-URL: documentation, https://github.com/crate-workbench/hubspot-tech-writing
Project-URL: homepage, https://github.com/crate-workbench/hubspot-tech-writing
Project-URL: repository, https://github.com/crate-workbench/hubspot-tech-writing
Keywords: html,hubspot,markdown,tech-writing
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Customer Service
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Telecommunications Industry
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Communications
Classifier: Topic :: Education
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Text Processing
Classifier: Topic :: Text Processing :: Markup
Classifier: Topic :: Text Processing :: Markup :: HTML
Classifier: Topic :: Text Processing :: Markup :: Markdown
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: beautifulsoup4<5
Requires-Dist: click<9
Requires-Dist: click-aliases<2
Requires-Dist: colorlog<7
Requires-Dist: hubspot-api-client<9
Requires-Dist: markdown<4
Requires-Dist: mkdocs-linkcheck<2
Requires-Dist: requests<3
Provides-Extra: develop
Requires-Dist: black<24; extra == "develop"
Requires-Dist: mypy==1.5.1; extra == "develop"
Requires-Dist: poethepoet<1; extra == "develop"
Requires-Dist: pyproject-fmt<1.2; extra == "develop"
Requires-Dist: ruff==0.0.291; extra == "develop"
Requires-Dist: validate-pyproject<0.15; extra == "develop"
Provides-Extra: release
Requires-Dist: build<2; extra == "release"
Requires-Dist: twine<5; extra == "release"
Provides-Extra: test
Requires-Dist: pytest<8; extra == "test"
Requires-Dist: pytest-cov<5; extra == "test"
Requires-Dist: pytest-mock<4; extra == "test"

# Technical Writing on HubSpot

[![Tests](https://github.com/crate-workbench/hubspot-tech-writing/actions/workflows/main.yml/badge.svg)](https://github.com/crate-workbench/hubspot-tech-writing/actions/workflows/main.yml)
[![Test coverage](https://img.shields.io/codecov/c/gh/crate-workbench/hubspot-tech-writing.svg)](https://codecov.io/gh/crate-workbench/hubspot-tech-writing/)
[![Python versions](https://img.shields.io/pypi/pyversions/hubspot-tech-writing.svg)](https://pypi.org/project/hubspot-tech-writing/)

[![License](https://img.shields.io/github/license/crate-workbench/hubspot-tech-writing.svg)](https://github.com/crate-workbench/hubspot-tech-writing/blob/main/LICENSE)
[![Status](https://img.shields.io/pypi/status/hubspot-tech-writing.svg)](https://pypi.org/project/hubspot-tech-writing/)
[![PyPI](https://img.shields.io/pypi/v/hubspot-tech-writing.svg)](https://pypi.org/project/hubspot-tech-writing/)
[![Downloads](https://pepy.tech/badge/hubspot-tech-writing/month)](https://pypi.org/project/hubspot-tech-writing/)


<!-- » [Documentation] -->

» [Changelog]
| [PyPI]
| [Issues]
| [Source code]
| [License]

[Changelog]: https://github.com/crate-workbench/hubspot-tech-writing/blob/main/CHANGES.md
[Documentation]: https://hubspot-tech-writing.readthedocs.io/
[Issues]: https://github.com/crate-workbench/hubspot-tech-writing/issues
[License]: https://github.com/crate-workbench/hubspot-tech-writing/blob/main/LICENSE
[PyPI]: https://pypi.org/project/hubspot-tech-writing/
[Source code]: https://github.com/crate-workbench/hubspot-tech-writing


## About

- Support writing technical documentation on [HubSpot].
- [Markdown] to HTML converter with a few bells and whistles relevant for creating
  HubSpot blog posts.
- Upload blog posts and files to the HubSpot API, using the [hubspot-api-python] package.
- See community request about »[Markdown Support for Technical Bloggers]«.


## Setup

```shell
pip install --upgrade hubspot-tech-writing
```

After installation, you can verify if it was successful.
```shell
hstw --version
```


## Usage

### Markup Conversion
You can convert a Markdown file on your workstation, and write the output to an HTML file.
```shell
wget -O original.md https://github.com/crate-workbench/hubspot-tech-writing/raw/main/tests/data/hubspot-blog-post-original.md
hstw convert original.md converted.html
```

Alternatively, convert a Markdown file at a remote location, and write the output to STDOUT.
```shell
hstw convert https://github.com/crate-workbench/hubspot-tech-writing/raw/main/tests/data/hubspot-blog-post-original.md
```

### Link Checker

In order to report about missing links to the web, or inline images, run the
link checker on your Markdown documents.
```shell
hstw linkcheck original.md
```

Alternatively, you can also use a remote resource here.
```shell
hstw linkcheck https://github.com/crate-workbench/hubspot-tech-writing/raw/main/tests/data/hubspot-blog-post-original.md
```

### HubSpot Upload

Uploading to HubSpot is mostly an iterative process, so you will most likely need to use the
program multiple times on the same resource. In order ease invocation, we recommend to define
an environment variable for storing your access token to the HubSpot API.
```shell
export HUBSPOT_ACCESS_TOKEN=pat-na1-e8805e92-b7fd-5c9b-adc8-2299569f56c2
```

Upload HTML file from workstation.
The name of the blog post will be derived from the file name.
```shell
hstw upload testdrive.html
```

Upload PNG image from workstation to folder path on hubfs.
```shell
hstw upload testdrive.png --folder-path=/foo/bar
```

Convert Markdown to HTML, upload the document under a different name, and also upload all
referenced images.
```shell
hstw upload /path/to/document.md --name=a-different-name --folder-path=/blog/2023/topic
```

For more detailed information about this feature, please refer to the inline help:
```shell
hstw upload --help
```

### HubSpot Delete

You can delete blog post and file entities, by their unique resource identifiers,
or by name resp. path.

```shell
# Delete blog post by resource identifier.
hstw delete post --id=138458225506
```

```shell
# Delete file by path.
hstw delete file --path=/testdrive/foo.png
```

For more detailed information about this feature, please refer to the inline help:
```shell
hstw delete --help
```


## Troubleshooting

### Blog posts may not contain embedded images

If you are uploading directly from GitHub, and run such a command,
```
hstw upload https://github.com/acme/foo-repo/raw/main/article.md --name=testdrive
```
only to receive an error message like this,
```json
{
  "correlationId": "4836e94d-e42b-47a1-afff-597d8b67ba93",
  "errorType": "BLOG_POST_CONTAINS_EMBEDDED_IMAGES",
  "message": "Blog posts may not contain embedded images. Please upload images to File Manager.",
  "status": "error"
}
```
you are most certainly using a "private" repository, where `hstw` does not have
access permissions to.


## Prior Art

- https://github.com/verypossible/hubmd
- https://github.com/danjamescrosby/markdown-to-hubspot-blog


[HubSpot]: https://www.hubspot.com/
[hubspot-api-python]: https://github.com/HubSpot/hubspot-api-python
[Markdown]: https://daringfireball.net/projects/markdown/
[Markdown Support for Technical Bloggers]: https://community.hubspot.com/t5/HubSpot-Ideas/Markdown-Support-for-Technical-Bloggers/idi-p/15724
