v0.1.1.5: Enhanced text format support (plaintext, syntax highlighting, markdown); comprehensive testing and documentation

This commit is contained in:
mbusc
2025-08-28 20:20:46 +02:00
parent 3c2c2b35e2
commit b30a36b884
4 changed files with 412 additions and 17 deletions

115
README.md
View File

@ -4,7 +4,7 @@ A C++ library for interacting with PrivateBin servers via the JSON API v1.3.
## Features
- **Text Paste Creation**: Create encrypted text pastes
- **Text Paste Creation**: Create encrypted text pastes with multiple formats
- **File Upload**: Upload files as encrypted pastes
- **Paste Retrieval**: Retrieve and decrypt pastes
- **Paste Deletion**: Delete pastes with deletion tokens
@ -12,6 +12,32 @@ A C++ library for interacting with PrivateBin servers via the JSON API v1.3.
- **Cross-Platform**: Support for Windows and Linux
- **Complete API**: Implementation of all PrivateBin v1.3 API functions
- **Automated Builds**: Platform-specific build scripts for easy compilation
- **Text Formatting**: Support for plaintext, syntax highlighting, and markdown
## Text Formatting Support
The library supports multiple text formats as defined in the [PrivateBin API v1.3](https://github.com/PrivateBin/PrivateBin/wiki/API):
### Available Formats
- **`plaintext`** - Plain text (default format)
- **`syntaxhighlighting`** - Syntax highlighting for code snippets
- **`markdown`** - Markdown formatting for rich text
### Format Usage
```c
#include "privatebinapi.h"
// Plain text format
create_paste(server, content, password, expiration, "plaintext", 0, 0, &url, &token);
// Syntax highlighting for code
create_paste(server, code_content, password, expiration, "syntaxhighlighting", 0, 0, &url, &token);
// Markdown formatting
create_paste(server, markdown_content, password, expiration, "markdown", 0, 0, &url, &token);
```
## File Upload Functionality
@ -150,7 +176,17 @@ cmake --build . --config Release
## Usage
### Simple Text Paste
### Text Paste with Formatting
The library supports multiple text formats as defined in the [PrivateBin API v1.3](https://github.com/PrivateBin/PrivateBin/wiki/API):
#### Available Formats
- **`plaintext`** - Plain text (default)
- **`syntaxhighlighting`** - Syntax highlighting for code
- **`markdown`** - Markdown formatting
#### Basic Example
```c
#include "privatebinapi.h"
@ -175,6 +211,57 @@ if (result == 0) {
}
```
#### Syntax Highlighting Example
```c
const char* code_content = R"(
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
)";
int result = create_paste(
"https://privatebin.net",
code_content,
NULL, // no password
"1week", // expiration
"syntaxhighlighting", // syntax highlighting format
0, // don't burn after reading
0 // no discussion
);
```
#### Markdown Example
```c
const char* markdown_content = R"(
# Header
This is **bold** and *italic* text.
## Code Block
```cpp
int x = 42;
std::cout << x << std::endl;
```
> This is a blockquote.
)";
int result = create_paste(
"https://privatebin.net",
markdown_content,
NULL, // no password
"1month", // expiration
"markdown", // markdown format
0, // don't burn after reading
0 // no discussion
);
```
### File Upload
```c
@ -208,7 +295,7 @@ The library contains a comprehensive example program that demonstrates both text
### Running the Example
```bash
# Run basic example (creates a text paste)
# Run basic example (tests all text formats)
./example
# Upload a file
@ -221,6 +308,12 @@ The library contains a comprehensive example program that demonstrates both text
./example --upload https://privatebin.net test.txt mypassword 1day 1 0
```
The basic example now demonstrates:
- **Plaintext format** - Simple text pastes
- **Syntax highlighting format** - Code with syntax highlighting
- **Markdown format** - Rich text formatting
- **Interactive format selection** - Shows available options
### Example Output
The example program demonstrates:
@ -234,12 +327,20 @@ The example program demonstrates:
### Functions
- `create_paste()` - Creates a text paste
- `create_paste()` - Creates a text paste with optional formatting
- `upload_file()` - Uploads a file
- `get_paste()` - Retrieves a paste
- `delete_paste()` - Deletes a paste
- `free_string()` - Frees memory
### Format Support
The `create_paste()` function supports the following formats as defined in the [PrivateBin API v1.3](https://github.com/PrivateBin/PrivateBin/wiki/API):
- **`plaintext`** - Default format for simple text
- **`syntaxhighlighting`** - Syntax highlighting for code snippets
- **`markdown`** - Markdown formatting for rich text
### Error Codes
- `0` - Success
@ -281,6 +382,12 @@ See [LICENSE](LICENSE) for details.
## Changelog
### v0.1.1.5 (2025-08-28)
- **NEW**: Enhanced text format support (plaintext, syntax highlighting, markdown)
- **NEW**: Comprehensive format testing in examples and integration tests
- **IMPROVED**: Better API documentation with format examples
- **IMPROVED**: Enhanced test coverage for all supported formats
### v0.1.1.4 (2025-08-28)
- **NEW**: Automated release creation script (`scripts/create_release.ps1`)
- **NEW**: Build scripts moved to `scripts/` directory for better organization