From 82d32ee761913c531698c8340aa0d91d0708f23e Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 7 Jul 2021 10:44:51 -0700 Subject: [PATCH] feat(playground): show "No output" on playgrounds that print nothing Fixes #1594 --- src/theme/book.js | 10 +++++++++- src/theme/css/general.css | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/theme/book.js b/src/theme/book.js index 5e386369..24ed97d0 100644 --- a/src/theme/book.js +++ b/src/theme/book.js @@ -133,7 +133,15 @@ function playground_text(playground) { body: JSON.stringify(params) }) .then(response => response.json()) - .then(response => result_block.innerText = response.result) + .then(response => { + if (response.result.trim() === '') { + result_block.innerText = "No output"; + result_block.classList.add("result-no-output"); + } else { + result_block.innerText = response.result; + result_block.classList.remove("result-no-output"); + } + }) .catch(error => result_block.innerText = "Playground Communication: " + error.message); } diff --git a/src/theme/css/general.css b/src/theme/css/general.css index 2cf347f9..63317b39 100644 --- a/src/theme/css/general.css +++ b/src/theme/css/general.css @@ -175,3 +175,7 @@ blockquote { margin: 5px 0px; font-weight: bold; } + +.result-no-output { + font-style: italic; +}