Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

66%
+2 −0
Q&A How can we format code examples so that they work on a range of devices?

We use Madcap Flare to produce a large documentation set that contains many code examples (primarily SQL, but also C++, Java, and Python) and command-line operations. When the doc set was first pl...

1 answer  ·  posted 3y ago by Monica Cellio‭  ·  last activity 3y ago by manassehkatz‭

#2: Post edited by user avatar Monica Cellio‭ · 2020-08-05T01:47:20Z (over 3 years ago)
#1: Initial revision by user avatar Monica Cellio‭ · 2020-08-05T01:32:56Z (over 3 years ago)
How can we format code examples so that they work on a range of devices?
We use Madcap Flare to produce a large documentation set that contains many code examples (primarily SQL, but also C++, Java, and Python) and command-line operations.  When the doc set was first planned, years ago, the people designing the layout assumed desktop browsers, as was the norm back then.  We know how to make most aspects of our doc set more responsive to viewport size and platform, but I'm not sure what to do about the code examples.

Flare uses a slightly augmented HTML for its source.  Our examples are all in &lt;pre&gt; blocks, with styling for syntax highlighting.  Regular text flows to fit the viewport, but you can't just wrap a Linux command line, and the results of wrapping code would sometimes be confusing unless a continuation character were used in ways that browsers usually don't.  Within the &lt;pre&gt; blocks we sometimes reformat unwieldy code or command lines onto multiple lines, using continuation characters and indentation to make things clear.  But we're doing that based on what looks good in the browser windows we're currently using, so none of this solves the tablet problem (let alone the phone problem).  And yes, we have heard from customers that they want to be able to consult our documentation on these devices.

How should we be approaching code examples in a multi-device world?  If we insert those manual line breaks to accommodate phones the doc will look terrible on a desktop; if we design for desktops then people using phones or some tablets have to scroll horizontally (which is a pretty terrible UX).  We host our documentation publicly and distribute an HTML archive; ideally we would like a solution that works in both contexts.  We can modify CSS, add Javascript, and adjust how we use Flare, but we cannot replace Flare or build separate versions for each target platform.  Being part of a larger corporation, we don't have full control of our webserver; server configuration changes might be possible but will certainly involve bureaucracy.

Is there, perhaps, some Javascript we can insert that detects the viewport size and *automatically* does "something reasonable" -- and what would "something reasonable" look like?