Skip to content

Commit

Permalink
Merge pull request #327 from evolvedbinary/bugfix/remove-image-hack
Browse files Browse the repository at this point in the history
Revert temp workaround for the mixed content condition
  • Loading branch information
adamretter authored Nov 14, 2024
2 parents eade495 + daacc87 commit 2c07510
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
4 changes: 3 additions & 1 deletion packages/lwdita-ast/src/nodes/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ export abstract class AbstractBaseNode implements BaseNode {
}

allowsMixedContent(): boolean {
return this.canAdd("text");
//This is a temporary solution REMOVE the alt node as it's not mixed content
// by YB, signed-off by AR.
return this.canAdd("text") || this.canAdd("alt");
}
}

Expand Down
15 changes: 3 additions & 12 deletions packages/lwdita-xdita/src/xdita-serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { AbstractBaseNode, AltNode, CDataNode, DocumentNode, TextNode } from "@evolvedbinary/lwdita-ast";
import { AbstractBaseNode, CDataNode, DocumentNode, TextNode } from "@evolvedbinary/lwdita-ast";
import { TextSimpleOutputStream } from "./stream";

/**
Expand Down Expand Up @@ -49,23 +49,14 @@ export class XditaSerializer {
this.EOL = '\n';
}

// Temporary fix for the serializer of images and fallback nodes see:
// https://evolvedbinaryltd.kanbanize.com/ctrl_board/16/cards/3516/details/
private serializeMixedContent(node: AbstractBaseNode) {
//This is a temporary solution REMOVE the alt node as it's not mixed content
// by YB, signed-off by AR.
const alt = new AltNode();
return node.allowsMixedContent() || node.canAddNode(alt);
}

/**
* Emit the indentation to the output stream
*
* @param node - the node to check if indentation can be added
*/
private serializeIndentation(node?: AbstractBaseNode): void {
if (!this.indent || !node) return;
if (this.serializeMixedContent(node)) return;
if (node.allowsMixedContent()) return;
this.outputStream.emit(this.indentation.repeat(this.depth * this.tabSize));
}

Expand All @@ -76,7 +67,7 @@ export class XditaSerializer {
*/
private serializeEOL(node?: AbstractBaseNode): void {
if (!this.indent || !node) return;
if (this.serializeMixedContent(node)) return;
if (node.allowsMixedContent()) return;
this.outputStream.emit(this.EOL);
}

Expand Down

0 comments on commit 2c07510

Please sign in to comment.