From 56e46bf77ce5d6f536678729766cf00f779ae1a4 Mon Sep 17 00:00:00 2001 From: bokuweb Date: Mon, 27 Mar 2023 17:35:15 +0900 Subject: [PATCH] fix: escape style name (#612) * fix: escape style name * fix: snaps * fix --- CHANGELOG.md | 4 ++++ docx-core/src/documents/elements/name.rs | 6 ++++-- docx-wasm/package.json | 2 +- docx-wasm/test/__snapshots__/index.test.js.snap | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8eb1c1..8bc87e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## docx-wasm@0.0.278-rc0 (27. Mar, 2023) + +- Fixed a bug, escape style name. + ## docx-wasm@0.0.277-rc1 (20. Dec, 2022) - Support `link` in style. diff --git a/docx-core/src/documents/elements/name.rs b/docx-core/src/documents/elements/name.rs index d7ebc18..6517837 100644 --- a/docx-core/src/documents/elements/name.rs +++ b/docx-core/src/documents/elements/name.rs @@ -3,7 +3,7 @@ use serde::{Serialize, Serializer}; use std::str::FromStr; use crate::documents::BuildXML; -use crate::xml_builder::*; +use crate::{escape, xml_builder::*}; #[derive(Debug, Clone, PartialEq)] pub struct Name { @@ -12,7 +12,9 @@ pub struct Name { impl Name { pub fn new(name: impl Into) -> Name { - Name { name: name.into() } + Name { + name: escape::escape(&name.into()), + } } pub fn starts_with(&self, s: &str) -> bool { diff --git a/docx-wasm/package.json b/docx-wasm/package.json index 3d4ab76..98735f6 100644 --- a/docx-wasm/package.json +++ b/docx-wasm/package.json @@ -1,6 +1,6 @@ { "name": "docx-wasm", - "version": "0.0.277-sdt5", + "version": "0.0.278-rc0", "main": "dist/node/index.js", "browser": "dist/web/index.js", "author": "bokuweb ", diff --git a/docx-wasm/test/__snapshots__/index.test.js.snap b/docx-wasm/test/__snapshots__/index.test.js.snap index cdbfbe6..a144e44 100644 --- a/docx-wasm/test/__snapshots__/index.test.js.snap +++ b/docx-wasm/test/__snapshots__/index.test.js.snap @@ -85755,7 +85755,7 @@ Object { }, Object { "basedOn": null, - "name": "F_BOLD&ALLCAPITAL", + "name": "F_BOLD&ALLCAPITAL", "next": null, "paragraphProperty": Object { "runProperty": Object {},