Skip to content

Commit

Permalink
0.7.3 - Add better preformatting support
Browse files Browse the repository at this point in the history
  • Loading branch information
vkottler committed Nov 21, 2024
1 parent 50312db commit 5246fb8
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
- run: |
mk python-release owner=vkottler \
repo=svgen version=0.7.2
repo=svgen version=0.7.3
if: |
matrix.python-version == '3.12'
&& matrix.system == 'ubuntu-latest'
Expand Down
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ good-names=p1,p2,x1,x2,y1,y2,rx,ry,cx,cy,dx,dy,x,y
disable=too-few-public-methods

[DESIGN]
max-args=7
max-positional-arguments=7
max-args=8
max-positional-arguments=8
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.4
hash=e3b8e71cf8f2ff14724ec99f593e1171
hash=29bb10f1b4ff2e59a4494421f8b4e3bd
=====================================
-->

# svgen ([0.7.2](https://pypi.org/project/svgen/))
# svgen ([0.7.3](https://pypi.org/project/svgen/))

[![python](https://img.shields.io/pypi/pyversions/svgen.svg)](https://pypi.org/project/svgen/)
![Build Status](https://github.com/vkottler/svgen/workflows/Python%20Package/badge.svg)
Expand Down
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 0
minor: 7
patch: 2
patch: 3
entry: svgen
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "svgen"
version = "0.7.2"
version = "0.7.3"
description = "A tool for working with scalable vector graphics."
readme = "README.md"
requires-python = ">=3.11"
Expand Down
4 changes: 2 additions & 2 deletions svgen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.4
# hash=9f3cbbe5ddb5066e39497cc0121eade3
# hash=4a9d6524eb23c9bce3184c85e0a13fc3
# =====================================

"""
Expand All @@ -10,4 +10,4 @@

DESCRIPTION = "A tool for working with scalable vector graphics."
PKG_NAME = "svgen"
VERSION = "0.7.2"
VERSION = "0.7.3"
13 changes: 10 additions & 3 deletions svgen/element/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(
children: List["Element"] = None,
allow_no_end_tag: bool = True,
class_str: str = None,
preformatted: bool = False,
**extra,
) -> None:
"""Construct a new SVG element."""
Expand All @@ -52,6 +53,8 @@ def __init__(
self.attributes: Dict[str, Attribute] = {}
self.booleans: set[str] = set()

self.preformatted = preformatted

for attr in attrib + attributes(extra):
self.add_attribute(attr)

Expand Down Expand Up @@ -124,14 +127,18 @@ def closing(self, indent: int = 0) -> str:
if not self.text and not self.children:
return " />" if self.allow_no_end_tag else ">" + close_tag

return (" " * (indent * INDENT)) + close_tag
return (
close_tag
if self.preformatted
else (" " * (indent * INDENT)) + close_tag
)

def _write_text(
self, output: TextIO, indent_str: str, newlines: bool = True
) -> None:
"""Write the inner-text section of this element."""

if not newlines:
if not newlines or self.preformatted:
output.write(self.text)
return

Expand All @@ -152,7 +159,7 @@ def encode(

# Indent will matter if we want lines.
indent_str = " " * (indent * INDENT)
if newlines:
if newlines and not self.preformatted:
output.write(indent_str)

attr_strs = [x.encode(quote) for x in self.attributes.values()] + list(
Expand Down

0 comments on commit 5246fb8

Please sign in to comment.